Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp82095iof; Sun, 5 Jun 2022 21:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG2TqkPobawogB1owzQxl9pq7msGKiuw87mkOByw4phQTotWFPp090r3+XfazUFDWH035L X-Received: by 2002:a17:90a:6b45:b0:1e3:3cfa:3104 with SMTP id x5-20020a17090a6b4500b001e33cfa3104mr34424838pjl.113.1654490931820; Sun, 05 Jun 2022 21:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654490931; cv=none; d=google.com; s=arc-20160816; b=QUsr5LXATquWRqArYk9QKUXzhcwbnS9lcJ0AsQSXQ+XWvXZKD75AS4Gjpj0kmFP6GY /8HbFeSF4fFqu1ozojkTKkZO7h5UNktkMacyukR5/RBlmxsrthZqBMOCc/Z8rMSZdjCE xYMRT150fwJXMiZnMPc1Evgg7lHcyR5ppxPP7Qey9ZJWVWHUTYWh+7ba/A8/+cUj8wyq SVGDJTrx6dIqIM6Ni8BOympeI6705eZheZPcCgOGi4tBXvkp/KBfwn0qJJMzLXb5+Dsm d3NLUh2G/Hj+VdojEg4C+qLRqEYNTFxh3dsSjAxFi1xlXKJcM3/AEAubXWJe+EJxtR9f dFIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=QI71ASgHrH+xXBDqvl4/z0d7wX86KydJWhZhtOf7+s8=; b=B+0AYU0TkjmXX1hpCnywfvTmCLaI5nZxdsFufvdfbXuULpBXiZHZfRqZLSgsxVAhdz yr9oNUwortEIYe5GrdlWO9U1vNx0chORaUE83D95eHLDxNzoDJcEu/pYYNLAt5CwlGjy WSItJFzOdBnDWgYEw4Odsx6Gp2+2bnK7cxPHMqdPQJSJ9RrN4FRlwOjXD/Oy+Wtd9LeY riFCKKNqGSJyS9jNosIz4gXN2lcozRiI+cmTFFOYwLCsvKK3pzxyczaPKKaTIyhcS+6d yuDzxC1K3yoL3obc0YYuBr6Lk48w7t3hQA1Ed1Et1R0PBgzCnPZ2u2en2Ky+WxPf6KJf P5QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hjCPrftM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c19-20020a170902849300b0015e84c97a93si18123033plo.111.2022.06.05.21.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:48:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hjCPrftM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B79539E9DB; Sun, 5 Jun 2022 21:06:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244386AbiFEHFY (ORCPT + 99 others); Sun, 5 Jun 2022 03:05:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350772AbiFEHFP (ORCPT ); Sun, 5 Jun 2022 03:05:15 -0400 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 80BB211479 for ; Sun, 5 Jun 2022 00:05:13 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id 3-20020a17090a174300b001e426a02ac5so12210011pjm.2 for ; Sun, 05 Jun 2022 00:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QI71ASgHrH+xXBDqvl4/z0d7wX86KydJWhZhtOf7+s8=; b=hjCPrftMwZz7tPzPMmyaoQIMbhhvFyTpqdG73CkJFmPSSnenqOPIhLrvna4ocmSQkI OkWJiIOVGjdEOXi7Muns+4StR/b9INtt51NmGm0fNIf/hnXRjcn7HU8cSR+3UZz6g1Yb YtKWhJ2ySst5PFYVqXGCMjl09K544KbbElnHGlheJPe8grHqmNbPMIOq8MP/JZb3fDs/ 7aMbvVwOdvEQiuFEpsZKM0K2JzTgbG0sqoucZyDSgepMDYjbUkKi5FOPH3rbzyE73rUQ Dr9Acq+mttFYO/clykkuFPzEtmKjI2hdDtxs0ZfkuivtbUyL9+ShGTlToHX3alY3dLCB roWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QI71ASgHrH+xXBDqvl4/z0d7wX86KydJWhZhtOf7+s8=; b=p9ts/6pW8Z/TxB0z5uwb7amzDdI2v++GpYeuZd5U52OIR1e4BqCEL+njC6D2izVFsN nmA1V9N7iAA3siO4klNF2HbB5RL4fDos13/W0HRKSnIIocaF2RJPAcMwBA+luOoK5z+B iHLYD2KefePQjDNrASxgfhDUwc9Msd4hC7T0ptf8Zhu7rXjkbWaTgoi1EGg4ZGMvL8jG zErkDrrfu4PV2wTF3euqWin28ddLh6P8aFNCX9h+PwoAaBEvuY2dOv6PuhWAQDBA2mNT qj9dfpEchiX406XHFgAKt4DlqFX6Hn5gkQodZmVLf8Qqfz2Zd4s3dTQyVkozTO+ybcdp gz7Q== X-Gm-Message-State: AOAM532NZmmYPLjxsmrgenMG/MpGt2O+7myOpfhNuECcT/IudrA4PE/q i6HDwTDJvC/j7+ctbxBD6y7Z1kurUH7kb9fvbh4= X-Received: by 2002:a17:90b:1194:b0:1e2:d261:202b with SMTP id gk20-20020a17090b119400b001e2d261202bmr40852106pjb.25.1654412713030; Sun, 05 Jun 2022 00:05:13 -0700 (PDT) MIME-Version: 1.0 References: <20220603143555.41914-1-sxwjean@me.com> In-Reply-To: From: Xiongwei Song Date: Sun, 5 Jun 2022 15:04:44 +0800 Message-ID: Subject: Re: [PATCH v2] mm/slub: Simplify __kmem_cache_alias() To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Xiongwei Song , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Muchun Song , "linux-mm @ kvack . org" , Linux Kernel Mailing List , Xiongwei Song Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Sat, Jun 4, 2022 at 5:43 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: > > On Fri, Jun 03, 2022 at 10:35:55PM +0800, sxwjean@me.com wrote: > > From: Xiongwei Song > > > > There is no need to do anything if sysfs_slab_alias() return nonzero > > value after getting a mergeable cache. > > > > Signed-off-by: Xiongwei Song > > Reviewed-by: Muchun Song > > --- > > v2: Collect Reviewed-by tag from Muchun. > > --- > > mm/slub.c | 8 +++----- > > 1 file changed, 3 insertions(+), 5 deletions(-) > > > > diff --git a/mm/slub.c b/mm/slub.c > > index d8d5abf49f5f..9444277d669a 100644 > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -4861,6 +4861,9 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, > > > > s = find_mergeable(size, align, flags, name, ctor); > > if (s) { > > + if (sysfs_slab_alias(s, name)) > > + return NULL; > > + > > s->refcount++; > > > > I think we should not expose sysfs attributes before initializing > what can be read via sysfs attribute (object_size). > > > /* > > @@ -4869,11 +4872,6 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, > > */ > > s->object_size = max(s->object_size, size); > > this calculation should be done before sysfs_slab_alias(). Yeah, understood. Should we restore s->object_size and s->inuse if sysfs_slab_alias() returns non zero value? Regards, Xiongwwei > > Thanks, > Hyeonggon > > > s->inuse = max(s->inuse, ALIGN(size, sizeof(void *))); > > - > > - if (sysfs_slab_alias(s, name)) { > > - s->refcount--; > > - s = NULL; > > - } > > } > > > > return s; > > -- > > 2.30.2 > > >