x86/ioperm: Share I/O bitmap if identical

The I/O bitmap is duplicated on fork. That's wasting memory and slows down
fork. There is no point to do so. As long as the bitmap is not modified it
can be shared between threads and processes.

Add a refcount and just share it on fork. If a task modifies the bitmap
then it has to do the duplication if and only if it is shared.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Andy Lutomirski <luto@kernel.org>
This commit is contained in:
Thomas Gleixner
2019-11-11 23:03:25 +01:00
parent ea5f1cd7ab
commit 4804e382c1
3 changed files with 50 additions and 42 deletions

View File

@@ -2,15 +2,20 @@
#ifndef _ASM_X86_IOBITMAP_H
#define _ASM_X86_IOBITMAP_H
#include <linux/refcount.h>
#include <asm/processor.h>
struct io_bitmap {
u64 sequence;
refcount_t refcnt;
/* The maximum number of bytes to copy so all zero bits are covered */
unsigned int max;
unsigned long bitmap[IO_BITMAP_LONGS];
};
struct task_struct;
void io_bitmap_share(struct task_struct *tsk);
void io_bitmap_exit(void);
void tss_update_io_bitmap(void);