Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14895439rwb; Mon, 28 Nov 2022 06:06:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf4SGmv7EbH+x7QkrPaT6gPM+503Kwx5Ytt361b0UaqHnPoIxQhkvfiy3MN+3X0gh/1mHn94 X-Received: by 2002:ac2:58f6:0:b0:4a2:7692:3a0a with SMTP id v22-20020ac258f6000000b004a276923a0amr17739993lfo.71.1669644416820; Mon, 28 Nov 2022 06:06:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669644416; cv=none; d=google.com; s=arc-20160816; b=ofIPSZB8DeT8irWps1DA0nkgXXQEbJ/gdVMvM02ZUJUC5RVE9yQvWk9A3MohdNZ3Id SS6ORgS3PwOiykwI9ROgpCtP3H3EW4nireOLf01z7n78nnlyTp6j9dCeQ4520SIBqJcf UCZL/4u2fy8S+IgePVs9F9G5MLgx9wnS7bKu8S42thOP6Tofsfik8SbACjFhB5q1VBDL 8uSchqXPWgHGTuhfnAFUUF/jijjhUmt0nfWbE6gC/L5G37RD/h0/iBtXpUhmExqdBu0v jnlXD8SAbH6XZUSxQQMcbQIt51tjvM0kSVREIcDggxtLQhV9emIc4zZsG65r7g1DNZhI dLRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=B3cwuU9wjQ8VbfKUTNnbiIt2B8/rOnQ22JV6mreBMhw=; b=gNFA3via4dqUGHkW5FGADYlQ7YANi3YnDTs025zOFhyijUuN5kHGPLpxAgbF2IcnA1 xLM9o96vY3bmi7wvvAbDbThgjNjtstAbnyvoc8Z4dDrl+pglPgvHZ/wQWwM7IpbAkQAR jWgHV2RunVMJkg7a/W9nUpQMFM6tgH+O3Qxp5aVddfvPbn6Tg2//My4lY2Pd5geECvmj fYcyWWs9RAd/gWvpboA/zquchsisNwzJjoCTKYqWVLynoTYfvJN9vm4L2LxE4I0P1cUF MKWEfKvTOyY3FVwGEy7WIw1NjeBpgUOcKJ0reGuHzK5BVok9mcDOkwlPO+UUlPSlzeHs tMRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cPT++xvo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc36-20020a1709071c2400b007b8b7da648dsi9725466ejc.658.2022.11.28.06.06.35; Mon, 28 Nov 2022 06:06:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cPT++xvo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231384AbiK1NGZ (ORCPT + 84 others); Mon, 28 Nov 2022 08:06:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbiK1NGX (ORCPT ); Mon, 28 Nov 2022 08:06:23 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBD8BBF6E for ; Mon, 28 Nov 2022 05:06:22 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id k5so9402666pjo.5 for ; Mon, 28 Nov 2022 05:06:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=B3cwuU9wjQ8VbfKUTNnbiIt2B8/rOnQ22JV6mreBMhw=; b=cPT++xvoRpH851YV9eYArPjV+xqU7oPu2rsB24Yh0VaoiI41HRHpq0BuI5kjhwJxrw OaauRFOykeddywo17as5H5aSfdb3k+ZRK1/HrbhkNJGO6DOeJi2sT+a4VpqYybQDQKis LaIAQLPbv5qwbRMFzzXZCxlxYom4ld5FpVwTHDRB9Kty4D6cM0eXW5bmtRdcMDJj7GSF rw1hW/1qPQQAtN9TTWY17ci9C9wYfKL4g6BZxDPd42udY0AUwikvzlnMDm+UuQjqRGvf uauJd5YIf+vCWVArhUPl5uZt/S+Jx2OzwUCUT7cex60mtf6t3INwYhhhtEWW/CCtmeFX 1Hcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=B3cwuU9wjQ8VbfKUTNnbiIt2B8/rOnQ22JV6mreBMhw=; b=J6dFMjbD17I3i4ZUvDPpP6SIhzyE0Ce6l0a9xTZWfi0KS14kAM1tx7OL8oN7kiXjC5 lxra/0aDDPfInE+tB3Bqa9ysg2k5cRrFedA+YbGufpYZAzCt8ioMQHo2J5/k1v5GUo0n KFTrfQhWNVumctoCD2KuVspcNnMGeS6DFsgBuouFKQwxpOPTNsltSUkARsD8BgSd3fA8 4spCJ63SydoQ4jpon0m173iu7MPXYJhV+44Rbpg1Ve8bIW4F++cYDAvpBudfbpe4i1bx Pqunwxw+33tAczbXlnu0OjpfcHxfTDCnQDTK9+Lo4dxrlXjJbJ/dzW8W63hjz49X9EAi KOhg== X-Gm-Message-State: ANoB5pmXeR8RxCmQw1gSt4k7e7bV9evChZtOpFJwLxLaE2MLOXCY/tDM oNMQ2Pj6gqoPC0csNDisT7w= X-Received: by 2002:a17:90a:7d0d:b0:1fa:b51d:8d83 with SMTP id g13-20020a17090a7d0d00b001fab51d8d83mr32931270pjl.169.1669640782164; Mon, 28 Nov 2022 05:06:22 -0800 (PST) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id w13-20020a170902e88d00b00183c67844aesm8889847plg.22.2022.11.28.05.06.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 05:06:21 -0800 (PST) Date: Mon, 28 Nov 2022 22:06:15 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka Cc: Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg , Roman Gushchin , Andrew Morton , Linus Torvalds , Matthew Wilcox , patches@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 09/12] mm, slub: split out allocations from pre/post hooks Message-ID: References: <20221121171202.22080-1-vbabka@suse.cz> <20221121171202.22080-10-vbabka@suse.cz> <863dfdbb-2efc-a1d4-3cb1-3edaa67f67bd@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <863dfdbb-2efc-a1d4-3cb1-3edaa67f67bd@suse.cz> X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 28, 2022 at 12:01:39AM +0100, Vlastimil Babka wrote: > On 11/27/22 11:54, Hyeonggon Yoo wrote: > > On Mon, Nov 21, 2022 at 06:11:59PM +0100, Vlastimil Babka wrote: > >> In the following patch we want to introduce CONFIG_SLUB_TINY allocation > >> paths that don't use the percpu slab. To prepare, refactor the > >> allocation functions: > >> > >> Split out __slab_alloc_node() from slab_alloc_node() where the former > >> does the actual allocation and the latter calls the pre/post hooks. > >> > >> Analogically, split out __kmem_cache_alloc_bulk() from > >> kmem_cache_alloc_bulk(). > >> > >> Signed-off-by: Vlastimil Babka > >> --- > >> mm/slub.c | 127 +++++++++++++++++++++++++++++++++--------------------- > >> 1 file changed, 77 insertions(+), 50 deletions(-) > > > > [...] > > > >> + > >> +/* Note that interrupts must be enabled when calling this function. */ > >> +int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size, > >> + void **p) > >> +{ > >> + int i; > >> + struct obj_cgroup *objcg = NULL; > >> + > >> + /* memcg and kmem_cache debug support */ > >> + s = slab_pre_alloc_hook(s, NULL, &objcg, size, flags); > >> + if (unlikely(!s)) > >> + return false; > >> + > >> + i = __kmem_cache_alloc_bulk(s, flags, size, p, objcg); > >> + > >> + /* > >> + * memcg and kmem_cache debug support and memory initialization. > >> + * Done outside of the IRQ disabled fastpath loop. > >> + */ > >> + if (i != 0) > >> + slab_post_alloc_hook(s, objcg, flags, size, p, > >> + slab_want_init_on_alloc(flags, s)); > > > > This patch looks mostly good but wondering what happens if someone calls it with size == 0 > > so it does not call slab_post_alloc_hook()? > > Hmm looks like in that case we miss doing obj_cgroup_put(objcg) in > memcg_slab_post_alloc_hook(). Good catch, thanks! > > Fixing up, also a "return false" from int function > (existed also before this patch). > > ----8<---- > diff --git a/mm/slub.c b/mm/slub.c > index b74c4664160e..88f0ce49caab 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -3888,10 +3888,13 @@ int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size, > int i; > struct obj_cgroup *objcg = NULL; > > + if (!size) > + return 0; > + > /* memcg and kmem_cache debug support */ > s = slab_pre_alloc_hook(s, NULL, &objcg, size, flags); > if (unlikely(!s)) > - return false; > + return 0; > > i = __kmem_cache_alloc_bulk(s, flags, size, p, objcg); With that, Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Thanks! -- Thanks, Hyeonggon