Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp651689pxt; Thu, 5 Aug 2021 08:26:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9eh1J0rJ+850bKM6nghC6zWuh4wXDl1yxVse6Z0F+EHJaz264jFYHMEVHr+s+CI0Mb8E+ X-Received: by 2002:aa7:c4d4:: with SMTP id p20mr7252414edr.382.1628177207466; Thu, 05 Aug 2021 08:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628177207; cv=none; d=google.com; s=arc-20160816; b=rjC2FLMiH2CLzo0/oa9XdRC8H/N453Zbfc4i/G4wb5eoZ9WAmrwReGoIKoXeBg0uJ0 XPE/RbI1aNJOQIwdsGQafnWO7T46y5AgyHJ038/zT6wYe1kARt9reDDS7dRYqG2NCD0x G5YOzlDu/A4Emaqh4Fdcy/Gb234gcaBF+eKz0cLMY3f8pjeJQZgtqYuMqB0VyeWTRd89 htjKL8/MHrorBjGP4cSzkt0v/HgiCLNGgBEp1voZxyZgzVY3uWzb4b8cLcmlhscML/+L P/Ot2vhPwD34er0/E+aWKeJbRyEGS3oOpY/6emGxpfAGZQPhaGflZIuyl6yIzYzoMZJ9 ZvEQ== 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=I+km54IEPBOKgP/D/7ZOaIi7iJCeyYI5BJRJug56I9U=; b=Qs/xjt70RdH42E1qam4noXBJHRel0q6IL4pfF38z4Rcw9VolEAwSC6CjODgdy0dTDv RUOhcEzh8/htWnxxxhXI0fn6ZYhBKthssZF9ygufBuf83/XiPwyiwPkQbBW2XvuaEZaI gq7tXvQe6GAEJhUXy0zTo0LRb2Yv0AbmzMgCd0NQaKgGgQmc4r0uNzdj/zj9HSPGtXFx p3I2+x7gqv8YtjQ3hM1D6VAqMpUJ4fjzflAon87YLOeavd3XeTCwvdpOzj/v6gNRqkmN Y0PqGiVwB6JhIxZvSZecWO6SC6vF/ekcxnEIOjMhnatWh8JCzBDeuRhcTs0lN+lokwrI zG5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lDXAMIyv; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=eiw1RcUF; 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 hq37si5839895ejc.56.2021.08.05.08.26.24; Thu, 05 Aug 2021 08:26:47 -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=lDXAMIyv; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=eiw1RcUF; 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 S242124AbhHEPZC (ORCPT + 99 others); Thu, 5 Aug 2021 11:25:02 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:59186 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241976AbhHEPUX (ORCPT ); Thu, 5 Aug 2021 11:20:23 -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-out2.suse.de (Postfix) with ESMTPS id 1AF1320251; Thu, 5 Aug 2021 15:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628176808; 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=I+km54IEPBOKgP/D/7ZOaIi7iJCeyYI5BJRJug56I9U=; b=lDXAMIyvlaG6mfBd1jCTB2dIbZMXqJjIoIb2C+TVMb1GxoQa5CymtXNqQiDaBCP89T6hDM /Gs5UnrvAZ/qqUGi1Gx2ioDsThcKhvacoT/vbc90YeSaj8JIe5UTDFyljdsmCDOVy01SeH kNftAVXufaFTU8IAbsEBNVJ55kjzwqE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628176808; 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=I+km54IEPBOKgP/D/7ZOaIi7iJCeyYI5BJRJug56I9U=; b=eiw1RcUFI1FkrToAj4XGAguk+9BLD80N/FvNfrOsFUG5Sl5YiT3UODroySMZ0lMxhVA3K9 h9j74kMOhHDUcpDA== 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 E586E13DAC; Thu, 5 Aug 2021 15:20:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OEFtN6cBDGFDdQAAMHmgww (envelope-from ); Thu, 05 Aug 2021 15:20:07 +0000 From: Vlastimil Babka To: Andrew Morton , Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Jann Horn , Vlastimil Babka Subject: [PATCH v4 21/35] mm, slub: call deactivate_slab() without disabling irqs Date: Thu, 5 Aug 2021 17:19:46 +0200 Message-Id: <20210805152000.12817-22-vbabka@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210805152000.12817-1-vbabka@suse.cz> References: <20210805152000.12817-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 27c98f4fb3f5..8de4ead2dbf3 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