Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6093970pxv; Thu, 29 Jul 2021 06:24:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMtgIuptTzFPeaTURjQfqV76K4GMuwOa/QAUWmFurTJHQhRkmbGjZ+DdNzji0uSydf3ac+ X-Received: by 2002:a5e:8d03:: with SMTP id m3mr4210221ioj.200.1627565048165; Thu, 29 Jul 2021 06:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627565048; cv=none; d=google.com; s=arc-20160816; b=ESamOYkjMq8LSY1spqC106OMjJudiC3NITG/DXyX64Kp7YKgdKH/25v1WG81Z6SIiK rTGgCysz9fmxFdU9YhZgJ1se1nG0PtKYnTtDIIOjxLKyyCTWI8mMl0b1EllmRRDRpsu6 HjZH32IdN3JeRiYiMbRUC3klBsc249B4FCquYbex/jS8AjZwrs1/HAvjnV+hYjTIX8Va cnuLUHh8A30aQBFmdSovUymGoHur/AYDtk0C5WaPEPI+qz1Dt6DCiPbnaNJFvgTpXDz0 M4sGNtNqlIwNjac0pZzsdoj/cw0NSZNIBjvpLCw/DH57xvH7wJkmuq4KcIrRjC13FWWG gfWQ== 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; bh=UiCxRMMHMOS5L/ydhMEkZsbsrTOn4byCcROCCC2JXf4=; b=G9CJVXYq2gcNzRed8JFZ6Scna5QUPVobemYKgekSkouW47kmtX9u7251F/htcs4hOd QRtKH5FH/zKK3I4B14Am2JAilj8bnMcYk+semZdj4b3CsDwPHX7vP4LjWzpVXlcaIhQX 2c52SL/3ivNb/h17/CwWOT3QNcZ0oyhuFvinxQKsTX6j8eEx+ZR4kkmk0VMPefG/NXlS FlJhk1eNt0bnZT8IQLkH9152vONg2jYXyrUOJGniZnqIA/eUHsTV25Fx/UkqpGfzJer4 c1CNjkwzVRurtg9PVwtYnYd6z4LQIkPBnZs0tMydW6jb/liugwgrWl6QxvGH+UNJrS9q 6gVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=PqH1P7qL; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=xEo5d3sa; 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 b12si3330131jal.75.2021.07.29.06.23.56; Thu, 29 Jul 2021 06:24: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=PqH1P7qL; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=xEo5d3sa; 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 S237680AbhG2NXA (ORCPT + 99 others); Thu, 29 Jul 2021 09:23:00 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:38376 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237512AbhG2NVr (ORCPT ); Thu, 29 Jul 2021 09:21:47 -0400 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 5D61B223CA; Thu, 29 Jul 2021 13:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1627564904; 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=UiCxRMMHMOS5L/ydhMEkZsbsrTOn4byCcROCCC2JXf4=; b=PqH1P7qLLkcXKDgXD6IE8BG16RZe41LGnaZXMz9YqjhUYdqHjc+cbQ3PT14w3bmOJ8C+DV 4uEFcVPFt4SKyvXaAOT5GPrP/sTXoRd9a+rYBFc0wzV5835nhCJDGz+yD13wBq8YXA+659 h2uf202DQq4LzHjNpIWtqA8lMuJicNQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1627564904; 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=UiCxRMMHMOS5L/ydhMEkZsbsrTOn4byCcROCCC2JXf4=; b=xEo5d3saBi/iGsw59tp8K87J57o+ylSeGBiXGkgb1x6d35m3p3gskxiUoQKHB1E9kmW1qG W39TPxCCe4ULtOCg== 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 2FCAA13AF4; Thu, 29 Jul 2021 13:21:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uArTCmirAmF9AwAAMHmgww (envelope-from ); Thu, 29 Jul 2021 13:21:44 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Jann Horn , Vlastimil Babka Subject: [PATCH v3 21/35] mm, slub: call deactivate_slab() without disabling irqs Date: Thu, 29 Jul 2021 15:21:18 +0200 Message-Id: <20210729132132.19691-22-vbabka@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210729132132.19691-1-vbabka@suse.cz> References: <20210729132132.19691-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 3d5a2f9371f8..1fdbc2ea8f67 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2749,8 +2749,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: @@ -2818,18 +2818,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.32.0