Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp125718rdb; Wed, 1 Nov 2023 20:26:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKxPuVzGTj32anLPe+ZhD1EyDjE1yn8PVy2PWlCFS6J1I8npFlRs4tQAFdfpJp/zYhPH/V X-Received: by 2002:a05:6830:6210:b0:6d3:1fff:f915 with SMTP id cd16-20020a056830621000b006d31ffff915mr2707490otb.23.1698895565309; Wed, 01 Nov 2023 20:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698895565; cv=none; d=google.com; s=arc-20160816; b=exxTmzKnXGvZKCsAL+MfX8ew4sxDdqr+wnjUnButKmm5m+VJzIV2zShu81eqYHR2VM ztvJEcpsfENg03Gda+Y5atbr0LK5zSwj9eTOmTCqcLuyrqv5pII+KOtUENzGdhm7J+GZ eyB6YQBvKgu4LbRgvRBUNUPfey1J2/vDF0w0DTMIaXlkPqhoThZe/1dT1HHTvk7vlm3j 6zcm0xLfu/9iQPES6a0PU3XsICn+OkJytAHVo1rm6sCNtXtBYS7GRSNCh7jE2LNBhhnZ lK8956BQeO48LhBUQWG1LTO0OtaUaI0bqy9/+ZFIoPB1ZPa7t6WeX8uImdF6CQA3Njb3 73aQ== 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; bh=SxN7Gc7oPUWEeX+rwHiBiXl514BfxOyW9F4Ey0p4ljE=; fh=Dd5ryTbz4gXtDU9jzXqg2hD87XusQgPqunF08GDmhnA=; b=y6ZtRZ8vtWz174RdTjqoaaZFz5NdCfbb+6BWApgHgdLlWAPPm0qk7SS6lqbfaC8igI oEXzlcjiC8CKh03inaznysialmFkbBUuANBZY7bK7PBkOjNgHQNxD0UtzxrsWaqTpH5i bqV9gZrT8uF/3CEqfYx0MNPrlohjT62DwbZB12GlVu2dHNU9Oe1Puyfj31lbKhDxEW9d w4RtUk2yMtzVpOcKUdqUYTkVBNB64/den2A6Ck2/5zs2YgNPgD9NJBj03i8ojWw8uNRu IEHnb9zsKqS8GlOML6LiUxquospUizeacZY/0GyxD4XzOSYEN+t0w7qSheVFHRCM8MFi B9ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=KQjfhe1X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id q8-20020aa79828000000b0068a6eb3b548si2676101pfl.401.2023.11.01.20.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 20:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=KQjfhe1X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1F67880C8DF5; Wed, 1 Nov 2023 20:25:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348343AbjKBDYs (ORCPT + 99 others); Wed, 1 Nov 2023 23:24:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348329AbjKBDYr (ORCPT ); Wed, 1 Nov 2023 23:24:47 -0400 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [IPv6:2001:41d0:203:375::aa]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96595110 for ; Wed, 1 Nov 2023 20:24:41 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698895480; h=from:from:reply-to:subject:subject: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=SxN7Gc7oPUWEeX+rwHiBiXl514BfxOyW9F4Ey0p4ljE=; b=KQjfhe1X0vzh80JaLfhIpxkVvacWOXmJrdGiki+nTBnVHkJnDiiAVRsK2kELO7fDNxvQI6 G6ybzeZ5YjP1xah95OqvCvgzwmI2JTnc6KOhO8JBYI5WOuwCfe9ULPpNMpW0LdOZ/2n96O //Wvc+JEmR8lCOYJBPeBl/5I81NJdYw= From: chengming.zhou@linux.dev To: vbabka@suse.cz, cl@linux.com, penberg@kernel.org Cc: rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, chengming.zhou@linux.dev, Chengming Zhou Subject: [PATCH v5 1/9] slub: Reflow ___slab_alloc() Date: Thu, 2 Nov 2023 03:23:22 +0000 Message-Id: <20231102032330.1036151-2-chengming.zhou@linux.dev> In-Reply-To: <20231102032330.1036151-1-chengming.zhou@linux.dev> References: <20231102032330.1036151-1-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 01 Nov 2023 20:25:09 -0700 (PDT) From: Chengming Zhou The get_partial() interface used in ___slab_alloc() may return a single object in the "kmem_cache_debug(s)" case, in which we will just return the "freelist" object. Move this handling up to prepare for later changes. And the "pfmemalloc_match()" part is not needed for node partial slab, since we already check this in the get_partial_node(). Signed-off-by: Chengming Zhou Reviewed-by: Vlastimil Babka Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slub.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 63d281dfacdb..0b0fdc8c189f 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3216,8 +3216,21 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, pc.slab = &slab; pc.orig_size = orig_size; freelist = get_partial(s, node, &pc); - if (freelist) - goto check_new_slab; + if (freelist) { + if (kmem_cache_debug(s)) { + /* + * For debug caches here we had to go through + * alloc_single_from_partial() so just store the + * tracking info and return the object. + */ + if (s->flags & SLAB_STORE_USER) + set_track(s, freelist, TRACK_ALLOC, addr); + + return freelist; + } + + goto retry_load_slab; + } slub_put_cpu_ptr(s->cpu_slab); slab = new_slab(s, gfpflags, node); @@ -3253,20 +3266,6 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, inc_slabs_node(s, slab_nid(slab), slab->objects); -check_new_slab: - - if (kmem_cache_debug(s)) { - /* - * For debug caches here we had to go through - * alloc_single_from_partial() so just store the tracking info - * and return the object - */ - if (s->flags & SLAB_STORE_USER) - set_track(s, freelist, TRACK_ALLOC, addr); - - return freelist; - } - if (unlikely(!pfmemalloc_match(slab, gfpflags))) { /* * For !pfmemalloc_match() case we don't load freelist so that -- 2.20.1