From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B147C04AA5 for ; Thu, 25 Aug 2022 13:11:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D522940008; Thu, 25 Aug 2022 09:11:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88519940007; Thu, 25 Aug 2022 09:11:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74D16940008; Thu, 25 Aug 2022 09:11:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 61D7E940007 for ; Thu, 25 Aug 2022 09:11:34 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 36D9B140436 for ; Thu, 25 Aug 2022 13:11:34 +0000 (UTC) X-FDA: 79838151708.25.9C05186 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf10.hostedemail.com (Postfix) with ESMTP id BEC04C0003 for ; Thu, 25 Aug 2022 13:11:33 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8770D344C1; Thu, 25 Aug 2022 13:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1661433092; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WCAuc8FWvjqnR5fEuXkcUAappoIRH5GZFA+NXq08iEA=; b=c3C6DntEiZuf/RhVUCjGM0P4qHgRiY+H6borHlSr1r3fL4AEGrWWK650Oa5cd7bt+AE5qD G8mzNhMTck18cTvm60VNktqL5VV7VUd0lRxJr8pCooPHkhmDMEf4HJmRFMlM9Mly5Brqdz PZ61nkD0g95ejPx9117DwGYME1Soa44= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1661433092; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WCAuc8FWvjqnR5fEuXkcUAappoIRH5GZFA+NXq08iEA=; b=KgsbqGNx93obxPdb3R+cJBZb+xAPMTkNVze7LKBsfFoK4dzCkUBsqFHozc61CQ03wma+YS iszqV7uzE75akCDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4B4AB13A8E; Thu, 25 Aug 2022 13:11:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Fx65EQR1B2PxKQAAMHmgww (envelope-from ); Thu, 25 Aug 2022 13:11:32 +0000 Message-ID: Date: Thu, 25 Aug 2022 15:11:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [PATCH] mm/slub: fix comments about fastpath limitation on PREEMPT_RT Content-Language: en-US To: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin Cc: Sebastian Andrzej Siewior , Thomas Gleixner , Mike Galbraith , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220825015722.1697209-1-42.hyeyoo@gmail.com> From: Vlastimil Babka In-Reply-To: <20220825015722.1697209-1-42.hyeyoo@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=c3C6DntE; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=KgsbqGNx; spf=pass (imf10.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661433093; a=rsa-sha256; cv=none; b=nrtxWJlChLqiCJBwYWxd2uHJLkkmlDeYQ5tFRxeTK2Mwo5lFLen0huqc+zd0Zmg6QnVOWE MmoQHU+arqND+vxhnAv8FyJENGyFecRhJB+guHyQ/RgwLbim6CiMYnatoCxtJB5Pa/KcPE TZKClxeMhZ4ZqNeKd4d9PluZ/5y7Y9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661433093; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WCAuc8FWvjqnR5fEuXkcUAappoIRH5GZFA+NXq08iEA=; b=FHI8aBmCPGW024Gc56cAyy+puk/DdNmO8KKL3AmNO/+LV65svethP/Dep3Zz+YAg0uddd+ QOnkhPPgm7u5WBVXGF9XUKJub9a4IZnGWnt0RXEGCftr9x7Nidu7nWzRh1R8Z79j/zWWVB oEvtvgxQVmINHjITeAb0s9OFfETMccw= X-Rspam-User: X-Rspamd-Queue-Id: BEC04C0003 X-Stat-Signature: gsk76cnxz4669js49f4ust38hkaqd99a Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=c3C6DntE; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=KgsbqGNx; spf=pass (imf10.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Server: rspam01 X-HE-Tag: 1661433093-874236 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 8/25/22 03:57, Hyeonggon Yoo wrote: > With PREEMPT_RT disabling interrupt is unnecessary as there is > no user of slab in hardirq context on PREEMPT_RT. > > The limitation of lockless fastpath on PREEMPT_RT comes from the fact > that local_lock does not disable preemption on PREEMPT_RT. > > Fix comments accordingly. > > Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Just FTR, as "slub: Make PREEMPT_RT support less convoluted" patch dealt with these comments already, there's now nothing left to apply from below. > --- > mm/slub.c | 23 ++++++++++++++--------- > 1 file changed, 14 insertions(+), 9 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 30c2ee9e8a29..aa42ac6013b8 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -100,7 +100,7 @@ > * except the stat counters. This is a percpu structure manipulated only by > * the local cpu, so the lock protects against being preempted or interrupted > * by an irq. Fast path operations rely on lockless operations instead. > - * On PREEMPT_RT, the local lock does not actually disable irqs (and thus > + * On PREEMPT_RT, the local lock does not actually disable preemption (and thus > * prevent the lockless operations), so fastpath operations also need to take > * the lock and are no longer lockless. > * > @@ -3185,10 +3185,12 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s, struct list_l > slab = c->slab; > /* > * We cannot use the lockless fastpath on PREEMPT_RT because if a > - * slowpath has taken the local_lock_irqsave(), it is not protected > - * against a fast path operation in an irq handler. So we need to take > - * the slow path which uses local_lock. It is still relatively fast if > - * there is a suitable cpu freelist. > + * slowpath has taken the local_lock which does not disable preemption > + * on PREEMPT_RT, it is not protected against a fast path operation in > + * another thread that does not take the local_lock. > + * > + * So we need to take the slow path which uses local_lock. It is still > + * relatively fast if there is a suitable cpu freelist. > */ > if (IS_ENABLED(CONFIG_PREEMPT_RT) || > unlikely(!object || !slab || !node_match(slab, node))) { > @@ -3457,10 +3459,13 @@ static __always_inline void do_slab_free(struct kmem_cache *s, > #else /* CONFIG_PREEMPT_RT */ > /* > * We cannot use the lockless fastpath on PREEMPT_RT because if > - * a slowpath has taken the local_lock_irqsave(), it is not > - * protected against a fast path operation in an irq handler. So > - * we need to take the local_lock. We shouldn't simply defer to > - * __slab_free() as that wouldn't use the cpu freelist at all. > + * a slowpath has taken the local_lock which does not disable > + * preemption on PREEMPT_RT, it is not protected against a > + * fast path operation in another thread that does not take > + * the local_lock. > + * > + * So we need to take the local_lock. We shouldn't simply defer > + * to __slab_free() as that wouldn't use the cpu freelist at all. > */ > void **freelist; >