[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191114130926.GP4114@hirez.programming.kicks-ass.net>
Date: Thu, 14 Nov 2019 14:09:26 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: David Laight <David.Laight@...LAB.COM>
Cc: Thomas Gleixner <tglx@...utronix.de>,
LKML <linux-kernel@...r.kernel.org>,
"x86@...nel.org" <x86@...nel.org>,
Linus Torvalds <torvalds@...uxfoundation.org>,
Andy Lutomirski <luto@...nel.org>,
Stephen Hemminger <stephen@...workplumber.org>,
Willy Tarreau <w@....eu>, Juergen Gross <jgross@...e.com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [patch V2 11/16] x86/ioperm: Share I/O bitmap if identical
On Thu, Nov 14, 2019 at 11:02:01AM +0000, David Laight wrote:
> From: Peter Zijlstra
> > Sent: 12 November 2019 09:15
> ...
> > > + /*
> > > + * If the bitmap is not shared, then nothing can take a refcount as
> > > + * current can obviously not fork at the same time. If it's shared
> > > + * duplicate it and drop the refcount on the original one.
> > > + */
> > > + if (refcount_read(&iobm->refcnt) > 1) {
> > > + iobm = kmemdup(iobm, sizeof(*iobm), GFP_KERNEL);
> > > + if (!iobm)
> > > + return -ENOMEM;
> > > + io_bitmap_exit();
> > refcount_set(&iobm->refcnd, 1);
> > > }
>
> What happens if two threads of the same process enter the above
> at the same time?
Suppose there's just the two threads, and both will change it. Then both
do copy-on-write and the original gets freed.
Powered by blists - more mailing lists