Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5038858pxj; Wed, 9 Jun 2021 07:50:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytlIxzv3OqXXUchALyoG7ShCMWy+abjenMpC/RB988oGjzeV2W7W6+iHRp8PS6TvToeAQT X-Received: by 2002:aa7:d54c:: with SMTP id u12mr30537273edr.242.1623250211787; Wed, 09 Jun 2021 07:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623250211; cv=none; d=google.com; s=arc-20160816; b=vzoTPEaAX0Bm3mSGVdOPKk239KCFEsZC4yugcSvd85Qf0PKZk0/uUDxT/Zkoqrg1Wh DKwq7BtQ+MIVsZzrl3LYThD2/eFeXqyzvQ7Sh8qJE0Q1qpeF2DQrQqwwN47VRrVD//gf OFc3tntI0iUr9Qw92DKHZQSugzYal0ljIiEi/aFTlxAPqHneHg4PKAtZvWrmr6FZPq6W KBPBfWYzS7rXSlQ3ZgY34N1m6o1t9cc/e+pQkYyA/tTN/VsxFKS8KN+XlH5FJZ+BtkCH OyAS1NB2KzvPvLpnSVkxakIc20VVekbN3CUSocZNP2DRzKmUDrBUSLkFF4YVrBKYhG37 25pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=8TMqHwk78Ooa/tKgDwDLFTYj62DqSJ+/+iH5D+PQaTw=; b=MBo2FEYSqMpmkvCD6Leph9zFN6PAZjwuu90V2eN6nX85dhkZtndXwev67aJqhHP5A7 AUU3rqvWYhuaCQSXQyRn4uNVuOVEZMqgtBmM4xQ26lVvKiBr2rEDPaYkPU73LSQl4x3q o+zXtQ1zlvxjBzKfjjte5clooLRUGs6dEcIQZ8hDFULpAYRTzS37q++3Qn7M+dSWG+pv GdsUmUYOC3bpYMG4Nw3/LYER+yeuEyI2eDfWnm0rsyK8juq/DGBCb63r3Z/ez0DoBizr LxFJ/qrtdvwCkyKaICWtb/7SV0bA515a77tytV1wM0CrmwjXUt+i+LlTt6j1MGAzlEFq zPNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="xNml2b/x"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=aRLQO7bh; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="xNml2b/x"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=aRLQO7bh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v12si2621920edw.236.2021.06.09.07.49.46; Wed, 09 Jun 2021 07:50:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="xNml2b/x"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=aRLQO7bh; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="xNml2b/x"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=aRLQO7bh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239248AbhFILmc (ORCPT + 99 others); Wed, 9 Jun 2021 07:42:32 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:54710 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239159AbhFILla (ORCPT ); Wed, 9 Jun 2021 07:41:30 -0400 Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AB664219E6; Wed, 9 Jun 2021 11:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623238775; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8TMqHwk78Ooa/tKgDwDLFTYj62DqSJ+/+iH5D+PQaTw=; b=xNml2b/xZFeXKSMw0bboB495jc9H0LIgaPrTmQ9wZF7BL6+w/h/ygalY3Wp7yJNfhg0Rp9 /G25JBQFDmIoLqMT1lYUlmtnvPoKOYrIOyA+3ecwHSqOI3OBYztII5j0U1u7b2F3R5fA/9 2gi40po9/AlLuEJT4DTgFLOsCnL3pps= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623238775; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8TMqHwk78Ooa/tKgDwDLFTYj62DqSJ+/+iH5D+PQaTw=; b=aRLQO7bhseIQlT/OaIBIyWHymfr1355G1zpwuBu8to6DqC5r/TZte6vvrjL93BAKyBoCjs ZJcw9FQY0eSgBBAA== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 7C72F11A98; Wed, 9 Jun 2021 11:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623238775; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8TMqHwk78Ooa/tKgDwDLFTYj62DqSJ+/+iH5D+PQaTw=; b=xNml2b/xZFeXKSMw0bboB495jc9H0LIgaPrTmQ9wZF7BL6+w/h/ygalY3Wp7yJNfhg0Rp9 /G25JBQFDmIoLqMT1lYUlmtnvPoKOYrIOyA+3ecwHSqOI3OBYztII5j0U1u7b2F3R5fA/9 2gi40po9/AlLuEJT4DTgFLOsCnL3pps= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623238775; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8TMqHwk78Ooa/tKgDwDLFTYj62DqSJ+/+iH5D+PQaTw=; b=aRLQO7bhseIQlT/OaIBIyWHymfr1355G1zpwuBu8to6DqC5r/TZte6vvrjL93BAKyBoCjs ZJcw9FQY0eSgBBAA== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id kDrlHXeowGD6XgAALh3uQQ (envelope-from ); Wed, 09 Jun 2021 11:39:35 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Peter Zijlstra , Jann Horn , Vlastimil Babka Subject: [RFC v2 21/34] mm, slub: call deactivate_slab() without disabling irqs Date: Wed, 9 Jun 2021 13:38:50 +0200 Message-Id: <20210609113903.1421-22-vbabka@suse.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210609113903.1421-1-vbabka@suse.cz> References: <20210609113903.1421-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function is now safe to be called with irqs enabled, so move the calls outside of irq disabled sections. When called from ___slab_alloc() -> flush_slab() we have irqs disabled, so to reenable them before deactivate_slab() we need to open-code flush_slab() in ___slab_alloc() and reenable irqs after modifying the kmem_cache_cpu fields. But that means a IRQ handler meanwhile might have assigned a new page to kmem_cache_cpu.page so we have to retry the whole check. The remaining callers of flush_slab() are the IPI handler which has disabled irqs anyway, and slub_cpu_dead() which will be dealt with in the following patch. Signed-off-by: Vlastimil Babka --- mm/slub.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index bba18146def6..a99a254f2410 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2706,8 +2706,8 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, freelist = c->freelist; c->page = NULL; c->freelist = NULL; - deactivate_slab(s, page, freelist); local_irq_restore(flags); + deactivate_slab(s, page, freelist); new_slab: @@ -2775,18 +2775,32 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, */ goto return_single; +retry_load_page: + local_irq_save(flags); - if (unlikely(c->page)) - flush_slab(s, c); + if (unlikely(c->page)) { + void *flush_freelist = c->freelist; + struct page *flush_page = c->page; + + c->page = NULL; + c->freelist = NULL; + c->tid = next_tid(c->tid); + + local_irq_restore(flags); + + deactivate_slab(s, flush_page, flush_freelist); + + stat(s, CPUSLAB_FLUSH); + + goto retry_load_page; + } c->page = page; goto load_freelist; return_single: - local_irq_save(flags); deactivate_slab(s, page, get_freepointer(s, freelist)); - local_irq_restore(flags); return freelist; } -- 2.31.1