From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-f176.google.com (mail-io0-f176.google.com [209.85.223.176]) by kanga.kvack.org (Postfix) with ESMTP id DF6606B0254 for ; Wed, 9 Sep 2015 11:44:05 -0400 (EDT) Received: by iofh134 with SMTP id h134so27034864iof.0 for ; Wed, 09 Sep 2015 08:44:05 -0700 (PDT) Received: from resqmta-ch2-06v.sys.comcast.net (resqmta-ch2-06v.sys.comcast.net. [2001:558:fe21:29:69:252:207:38]) by mx.google.com with ESMTPS id a19si2576100igr.29.2015.09.09.08.44.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 09 Sep 2015 08:44:04 -0700 (PDT) Date: Wed, 9 Sep 2015 10:44:03 -0500 (CDT) From: Christoph Lameter Subject: Re: Is it OK to pass non-acquired objects to kfree? In-Reply-To: Message-ID: References: Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Dmitry Vyukov Cc: Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , "linux-mm@kvack.org" , Andrey Konovalov , Alexander Potapenko , Paul McKenney On Wed, 9 Sep 2015, Dmitry Vyukov wrote: > Things do not work this way for long time. If you read > Documentation/memory-barriers.txt or ARM/POWER manual and C language > standard, you will see that memory accesses from different threads can > be reordered (as perceived by other threads). So kmalloc still can be > running when the pointer to the newly allocated object is assigned to > a global (thus making it available for other threads, which can, in > particular, call kfree). Guess this means that cachelines (A) may not have been be written back to memory when the pointer to the object is written to another cacheline(B) and that cacheline B arrives at the other processor first which has outdated cachelines A in its cache? So the other processor uses the contents of B to get to the pointer to A but then accesses outdated information since the object contents cachelines (A) have not arrive there yet? Ok lets say that is the case then any write attempt to A results in an exclusive cacheline state and at that point the cacheline is going to reflect current contents. So if kfree would write to the object then it will have the current information. Also what does it matter for kfree since the contents of the object are no longer in use? Could you please come up with a concrete example where there is brokenness that we need to consider. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org