Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5040192pxj; Wed, 9 Jun 2021 07:52:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYWaUd7t5xhQAiQTQSU4sEAvkUGz6aW56cIok8EG1qhHimulH3fWExaG6MTR2nzuxt2h8S X-Received: by 2002:a17:906:68c1:: with SMTP id y1mr290708ejr.32.1623250328083; Wed, 09 Jun 2021 07:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623250328; cv=none; d=google.com; s=arc-20160816; b=ubVYXgOsjhlXyR9ahB5NldKG2296imcXbsOBxpAZMHg8B8zkjyvPEVh34r7JZ5WG1t kdKM+DB+3o26SsOJygxk+cKQWbMw/nsYjEkN+wBlLWi4aBxOCryTxfLO7ruMd2PL9zAs NQVpWrAkzfCmAuLd55vq542q4Y8dSBZwKiJyjYGlA6s+mVsrmtBEiGb3D6p55gjPbe1n bvkE6cxXm7zFpzkrwJ/7M7r2Fmj1YfdJ8Eyr2dAPeT5sRiII6BxmrtFoHUW8LCAVnxfs a6ng0cNJN0JyFAOcUblUfpLuHI3llPnXOOc01BRFrspkPBEtphd7XQ3f3wz/i1xU8IkA Lx8g== 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=ufCLnw446ARgJJPk9KebxnNiU/kr4b5YrNsPcsD6jYQ=; b=ycgDDuYhmTLb3ajYDx6ZbJWiFl4KM0mlPbeZPydQJibJb0mjFoRSJ+51148n2XWw97 6Q5cjzHIV86phzyOsZFHtFAEguRyOgxFyCIFzd/BSPZpztyCRdPYZPPAKBMMTaMRNEzp 93f2U2Ze7n982Q8ASETvIJwCWdtC7lP43vfRK6MfDzH7OEo9fCW/vR8EMKbXQp7aBxcQ fzAl83bufeyXtf3I+tZeVKzFTLUwLd94jKxhc35ylOhdBiEQzAXcJdt5ktgliGxNGudM b+YROJcmreQfhT94ySN1rbDOJi25psceN2Iba/xRPhfXnOaQeIO6Q9fmHksUhP2/2Xoz iDAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZCNw0ycc; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=uUS8PbDZ; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZCNw0ycc; dkim=neutral (no key) header.i=@suse.cz; 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 m19si2709136edc.271.2021.06.09.07.51.44; Wed, 09 Jun 2021 07:52:08 -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=ZCNw0ycc; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=uUS8PbDZ; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZCNw0ycc; dkim=neutral (no key) header.i=@suse.cz; 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 S239237AbhFILmh (ORCPT + 99 others); Wed, 9 Jun 2021 07:42:37 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47068 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239160AbhFILla (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-out2.suse.de (Postfix) with ESMTPS id 5409A1FD68; Wed, 9 Jun 2021 11:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623238774; 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=ufCLnw446ARgJJPk9KebxnNiU/kr4b5YrNsPcsD6jYQ=; b=ZCNw0yccEZ8Xvn7x28T67xwao91S9+d40P9Zmc9Q0graNP0VzIly8pjulg5dqbpS3OkLXa GRk7UtYiQqX1UqrEVDLhFXwsuU/fu8lrMk1xH3yC1HRxO+uQxotdGTvMYd2PUa/ubH2ROo 2tpqz4/bjPI55ZT+arcT5Gg6rz7NXuo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623238774; 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=ufCLnw446ARgJJPk9KebxnNiU/kr4b5YrNsPcsD6jYQ=; b=uUS8PbDZQ3vjf+0vBxFfUtrq/RkVGkXpJ/yNGK6v3cDJ8ufqr1h55Ok9ZUMvPqC/4n+Ff6 3BctD7jrmKsYpVCg== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 24BE1118DD; Wed, 9 Jun 2021 11:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623238774; 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=ufCLnw446ARgJJPk9KebxnNiU/kr4b5YrNsPcsD6jYQ=; b=ZCNw0yccEZ8Xvn7x28T67xwao91S9+d40P9Zmc9Q0graNP0VzIly8pjulg5dqbpS3OkLXa GRk7UtYiQqX1UqrEVDLhFXwsuU/fu8lrMk1xH3yC1HRxO+uQxotdGTvMYd2PUa/ubH2ROo 2tpqz4/bjPI55ZT+arcT5Gg6rz7NXuo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623238774; 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=ufCLnw446ARgJJPk9KebxnNiU/kr4b5YrNsPcsD6jYQ=; b=uUS8PbDZQ3vjf+0vBxFfUtrq/RkVGkXpJ/yNGK6v3cDJ8ufqr1h55Ok9ZUMvPqC/4n+Ff6 3BctD7jrmKsYpVCg== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id WIR6CHaowGD6XgAALh3uQQ (envelope-from ); Wed, 09 Jun 2021 11:39:34 +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 14/34] mm, slub: move disabling irqs closer to get_partial() in ___slab_alloc() Date: Wed, 9 Jun 2021 13:38:43 +0200 Message-Id: <20210609113903.1421-15-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 Continue reducing the irq disabled scope. Check for per-cpu partial slabs with first with irqs enabled and then recheck with irqs disabled before grabbing the slab page. Mostly preparatory for the following patches. Signed-off-by: Vlastimil Babka --- mm/slub.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 22b5bfef8aa6..acb5e8f1d9da 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2633,11 +2633,6 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, if (unlikely(node != NUMA_NO_NODE && !node_isset(node, slab_nodes))) node = NUMA_NO_NODE; - local_irq_save(flags); - if (unlikely(c->page)) { - local_irq_restore(flags); - goto reread_page; - } goto new_slab; } redo: @@ -2678,6 +2673,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, if (!freelist) { c->page = NULL; + local_irq_restore(flags); stat(s, DEACTIVATE_BYPASS); goto new_slab; } @@ -2707,12 +2703,19 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, goto reread_page; } deactivate_slab(s, page, c->freelist, c); + local_irq_restore(flags); new_slab: - lockdep_assert_irqs_disabled(); - if (slub_percpu_partial(c)) { + local_irq_save(flags); + if (unlikely(c->page)) { + local_irq_restore(flags); + goto reread_page; + } + if (unlikely(!slub_percpu_partial(c))) + goto new_objects; /* stolen by an IRQ handler */ + page = c->page = slub_percpu_partial(c); slub_set_percpu_partial(c, page); local_irq_restore(flags); @@ -2720,6 +2723,16 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, goto redo; } + local_irq_save(flags); + if (unlikely(c->page)) { + local_irq_restore(flags); + goto reread_page; + } + +new_objects: + + lockdep_assert_irqs_disabled(); + freelist = get_partial(s, gfpflags, node, &page); if (freelist) { c->page = page; @@ -2752,15 +2765,18 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, check_new_page: if (kmem_cache_debug(s)) { - if (!alloc_debug_processing(s, page, freelist, addr)) + if (!alloc_debug_processing(s, page, freelist, addr)) { /* Slab failed checks. Next slab needed */ + c->page = NULL; + local_irq_restore(flags); goto new_slab; - else + } else { /* * For debug case, we don't load freelist so that all * allocations go through alloc_debug_processing() */ goto return_single; + } } if (unlikely(!pfmemalloc_match(page, gfpflags))) -- 2.31.1