Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755854AbdLVBa2 (ORCPT ); Thu, 21 Dec 2017 20:30:28 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51128 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755414AbdLVBa1 (ORCPT ); Thu, 21 Dec 2017 20:30:27 -0500 Date: Thu, 21 Dec 2017 17:30:36 -0800 From: "Paul E. McKenney" To: Matthew Wilcox Cc: rao.shoaib@oracle.com, linux-kernel@vger.kernel.org, brouer@redhat.com, linux-mm@kvack.org Subject: Re: [PATCH] Move kfree_call_rcu() to slab_common.c Reply-To: paulmck@linux.vnet.ibm.com References: <1513844387-2668-1-git-send-email-rao.shoaib@oracle.com> <20171221155434.GT7829@linux.vnet.ibm.com> <20171221170628.GA25009@bombadil.infradead.org> <20171222012741.GZ7829@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171222012741.GZ7829@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17122201-0052-0000-0000-00000295A16A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008240; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00963688; UDB=6.00487556; IPR=6.00743675; BA=6.00005753; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018666; XFM=3.00000015; UTC=2017-12-22 01:30:23 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17122201-0053-0000-0000-000052FAEF1B Message-Id: <20171222013036.GB21720@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-21_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712220018 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3386 Lines: 67 On Thu, Dec 21, 2017 at 05:27:41PM -0800, Paul E. McKenney wrote: > On Thu, Dec 21, 2017 at 09:06:28AM -0800, Matthew Wilcox wrote: > > On Thu, Dec 21, 2017 at 07:54:34AM -0800, Paul E. McKenney wrote: > > > > +/* Queue an RCU callback for lazy invocation after a grace period. > > > > + * Currently there is no way of tagging the lazy RCU callbacks in the > > > > + * list of pending callbacks. Until then, this function may only be > > > > + * called from kfree_call_rcu(). > > > > > > But now we might have a way. > > > > > > If the value in ->func is too small to be a valid function, RCU invokes > > > a fixed function name. This function can then look at ->func and do > > > whatever it wants, for example, maintaining an array indexed by the > > > ->func value that says what function to call and what else to pass it, > > > including for example the slab pointer and offset. > > > > > > Thoughts? > > > > Thought 1 is that we can force functions to be quad-byte aligned on all > > architectures (gcc option -falign-functions=...), so we can have more > > than the 4096 different values we currently use. We can get 63.5 bits of > > information into that ->func argument if we align functions to at least > > 4 bytes, or 63 if we only force alignment to a 2-byte boundary. I'm not > > sure if we support any architecture other than x86 with byte-aligned > > instructions. (I'm assuming that function descriptors as used on POWER > > and ia64 will also be sensibly aligned). > > I do like this approach, especially should some additional subsystems > need this sort of special handling from RCU. It is also much faster > to demultiplex than alternative schemes based on address ranges and > the like. Oh, and having four-byte alignment would allow making laziness orthogonal to special handling, which should improve energy efficiency of callback handling by allowing normal call_rcu() callbacks to invoke laziness. (And would require renaming the call_rcu_lazy() API yet again, sorry Rao!) Thanx, Paul > How many bits are required by slab? Would ~56 bits (less the bottom > bit pattern reserved for function pointers) suffice on 64-bit systems > and ~24 bits on 32-bit systems? That would allow up to 256 specially > handled situations, which should be enough. (Famous last words!) > > > Thought 2 is that the slab is quite capable of getting the slab pointer > > from the address of the object -- virt_to_head_page(p)->slab_cache > > So sorting objects by address is as good as storing their slab caches > > and offsets. > > Different slabs can in some cases interleave their slabs of objects, > right? It might well be that grouping together different slabs from > the same slab cache doesn't help, but seems worth my asking the question. > > > Thought 3 is that we probably don't want to overengineer this. > > Just allocating a 14-entry buffer (along with an RCU head) is probably > > enough to give us at least 90% of the wins that a more complex solution > > would give. > > Can we benchmark this? After all, memory allocation can sometimes > counter one's intuition. > > One alternative approach would be to allocate such a buffer per > slab cache, and run each slab caches through RCU independently. > Seems like this should allow some savings. Might not be worthwhile, > but again seemed worth asking the question. > > Thanx, Paul