Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1443881ybt; Sun, 14 Jun 2020 23:46:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqtQinCRHIDLNbv8/M7UfIOOHjv2BQZy3lfM6K9zPNYlrRhrRyHEiG1zCtup9WwHyAwbbd X-Received: by 2002:a17:906:b88c:: with SMTP id hb12mr23748856ejb.483.1592203590116; Sun, 14 Jun 2020 23:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592203590; cv=none; d=google.com; s=arc-20160816; b=Su89xbTylXIEzW6MqvvZWjDVBb8dsZl3pgA5Vf5yqxCYkiiUUPlofAW1ooTMx+2zFi 8lKF7bpHE/8TmQuzglwhMlgukxef026GwEi2gAH3kf6yub3EunWglmeKfvxZn6w1AuTw uefST6yCLBN3nVuNotZz5r369xJJZBG7ybWwH2uiCYmQfdi6U01n6u9ZGQxwtURU7aZW MFc/yT+KbncRC1B3Jht2LUeVZB2xjTxPtpMhDoSzveygof0bYjh9/Zqyv5lRmMQx4HXX DhHCzJrPcmt7TCkLQSd+EgI2hx+uYX4h6WTYvLGG+6FL84+NNd+gtv+tGFR7X4ImV8/2 07/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=bK0Qp6h6dwfemWmyvHsC+Wip59HhIpavOmMER/ZWjbw=; b=dwsCjMoSuqvzR9RA1MBlXgUywIjUGNpUgrEMLGCGd/E8sAQtxV7ZsEuJxvXFp5OSV6 nywA12iQGV9gke/dt68Fjj/BaWr1KTGmtNOllDZihVf9kQ2OCwGmGMM15aWzL8srB2eD i2pK9ZexDNH2zQ9208mu2eOPGnLTro/0Os4157Qo/6aWpwqEEqWSLpnw2vctIU6NUF39 ShuKuOJ9LazWNwngHKojler2nW3YxZtK6B9Yw9tcK0Dbmu+Vwt/72s1NU81nB/zZT3b7 Lg8fGQ8HstfLAj0oiDAciT+RaTv4aG9k+VfKFX4wDi1p/0AeKiSoQxDK04vAiOZzJYCu Oi/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=oNj8hWZt; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si8446033edf.128.2020.06.14.23.46.07; Sun, 14 Jun 2020 23:46:30 -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=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=oNj8hWZt; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728319AbgFOGl5 (ORCPT + 99 others); Mon, 15 Jun 2020 02:41:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726111AbgFOGl4 (ORCPT ); Mon, 15 Jun 2020 02:41:56 -0400 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EBA2C061A0E for ; Sun, 14 Jun 2020 23:41:56 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id z2so14252335ilq.0 for ; Sun, 14 Jun 2020 23:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=bK0Qp6h6dwfemWmyvHsC+Wip59HhIpavOmMER/ZWjbw=; b=oNj8hWZtqPfHdMws2rjs6Zk9srH9hbdHfv4lMssnWJONTrkBSWKZ/qkpqhTrc0kG2X KpMM55sKx6/MSq9CpAj3L6i1BnwfQnWPAWfbhvkzsIed7u+BuvCZDOA6Rk4o0aIo09rH DO/OIb1SuKDxpoLs6tm8UFJ5vMWJCTCTYxys2qj8r/1Zf9s/9fDYAWLCCzsZdsludgj8 Wy7gr8hb9yBkBgEXVmAEu5FUDPaYeLzCAvguRIPcFpvViOK2gBD28JilN8FFa5EKJ2p8 VqTnw2KN+SWWaFZrNYDtKofXfUjNfZtMYsN2IMEI7vqPpJPNw133B+5Yez8b3PNDCLhE 4HTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=bK0Qp6h6dwfemWmyvHsC+Wip59HhIpavOmMER/ZWjbw=; b=bjp1jp81UG2T6SCuDuvKNDUscgrx3qcwzceOgnNBGJjLGrMGEgML5+EooGWupLsZXc ZR8fvz0qcltpV5k/Q2vJRVsuAeEmoraqa+tnVRcTfB0cvvcsZTfsEiQgMOZX+GMoK4Me VFahEVi9Io2LSEYsCxcGoA3bMdyh0EHRNkr0nx2QODZ8ivdICKFjrcrbKL91gn7cEOwQ aCI6mBDzzrRXLvyA7GmfOHM2tgc6rvrmBQfVEeqFjxgj7dJGbMprfnlxQ+cy6ZnXQOdo FvydpDUXbA6wvEG+c043zN/L4RcujXKlHS2YMIqXq9Q7n3rNHdDF/EiT01UVrBh6JniS +aCA== X-Gm-Message-State: AOAM532kTf8/o9vx2iIcRJ0yl786pZjfrKQEtBBU9Y3XYqSF5hhhyNlH YT6wdQu0aVfoafm9BPp1Xml6U0r7ZqbYnBtaTqmJsQ== X-Received: by 2002:a92:d1d0:: with SMTP id u16mr24697660ilg.2.1592203315520; Sun, 14 Jun 2020 23:41:55 -0700 (PDT) MIME-Version: 1.0 References: <20200614123923.99189-1-songmuchun@bytedance.com> <20200614123923.99189-4-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Mon, 15 Jun 2020 14:41:19 +0800 Message-ID: Subject: Re: [External] Re: [PATCH 3/3] mm/slub: Fix release all resources used by a slab cache To: Joonsoo Kim Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 15, 2020 at 2:23 PM Joonsoo Kim wrote: > > 2020=EB=85=84 6=EC=9B=94 14=EC=9D=BC (=EC=9D=BC) =EC=98=A4=ED=9B=84 9:39,= Muchun Song =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84= =B1: > > > > The function of __kmem_cache_shutdown() is that release all resources > > used by the slab cache, while currently it stop release resources when > > the preceding node is not empty. > > > > Signed-off-by: Muchun Song > > --- > > mm/slub.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/mm/slub.c b/mm/slub.c > > index b73505df3de2..4e477ef0f2b9 100644 > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -3839,6 +3839,7 @@ bool __kmem_cache_empty(struct kmem_cache *s) > > */ > > int __kmem_cache_shutdown(struct kmem_cache *s) > > { > > + int ret =3D 0; > > int node; > > struct kmem_cache_node *n; > > > > @@ -3846,11 +3847,11 @@ int __kmem_cache_shutdown(struct kmem_cache *s) > > /* Attempt to free all objects */ > > for_each_kmem_cache_node(s, node, n) { > > free_partial(s, n); > > - if (node_nr_slabs(n)) > > - return 1; > > + if (!ret && node_nr_slabs(n)) > > + ret =3D 1; > > } > > I don't think that this is an improvement. > > If the shutdown condition isn't met, we don't need to process further. > Just 'return 1' looks okay to me. > > And, with this change, sysfs_slab_remove() is called even if the > shutdown is failed. > It's better not to have side effects when failing. If someone calls __kmem_cache_shutdown, he may want to release resources used by the slab cache as much as possible. If we continue, we may release more pages. From this point, is it an improvement? --=20 Yours, Muchun