Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3781568pxf; Mon, 15 Mar 2021 19:32:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvC+xSvgIhxnu4eWYUERu7qmEuU+IhfVTGLK5WuiPkdZQ6IyWwia920OvQuvu28WuIVCxg X-Received: by 2002:a17:906:8443:: with SMTP id e3mr26512282ejy.370.1615861966891; Mon, 15 Mar 2021 19:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615861966; cv=none; d=google.com; s=arc-20160816; b=qxYLkQN2a3DvaJtzt+eXr2wlJ5jDntWemuZpCvAGeJA7n05v28haXX6U8iaFb/Aj/D +OhpjrpH6PQ/1GmZo5M0Bm53SqmLc/MHU9ItSHfIyqOydwLtu8vJzlzT8FBHwfyPIAoI bHVCM9eXDUfIJ5IkztGnN5XAV5wsHFYm6SzVSINjwaN0KJo0c9afo8PiYHjRRyw6Zua1 Bff7Ja+cFa0ijlevrcJdeQAynOvcJs3WJOBx82bC+GNwu+C0Jt8kmiu9r5opK1XK9o5J cZUC9XsjWrLmLTYXqbUSYPkyzgykHTzzyYQ/OVqH8IJ9/NmHPaJkAs6V8X2fwMzOLlrA cW2Q== 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=VN2QmRBHk/YVrYYtE6i8DWZ5kx35s2uQPi/cXaUiXgQ=; b=UdzRrio2OR62tFnJMCuO+LKKW6XeAhUaaTVJ915mCFtDEmxfQYq94Pxki/qhxLA3xk azkzIATUsCwR6pta0UaCQOBVvYxqYy2j3x4UG9EhYsDonkUYv3yu90lsGKdEoNAsYJ1U i/3wf8kuHZeYZKdLnRXXgjzUmJIKqYYR5ABLs61i8ZL0EqYynqs2RrRhiC3hTyzJx6B/ +l+IuckHLw52GdABWTVuQbSCXDXCcgQDVeL2QNqRX+zboBtZG/jSr9J/c+OyJ2MBlalf 69AKDRF0d9b3A+nvzI3dn1WPOTXs6MJfuKU3Z0fVrvtmTEdX0l+dJMs+kmWPw0rt4G/7 afWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Vp5kqbAT; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k24si13595413eja.161.2021.03.15.19.32.24; Mon, 15 Mar 2021 19:32:46 -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=@gmail.com header.s=20161025 header.b=Vp5kqbAT; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233430AbhCOTXF (ORCPT + 99 others); Mon, 15 Mar 2021 15:23:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231540AbhCOTWj (ORCPT ); Mon, 15 Mar 2021 15:22:39 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02F07C06174A for ; Mon, 15 Mar 2021 12:22:39 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id w18so18704027edc.0 for ; Mon, 15 Mar 2021 12:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VN2QmRBHk/YVrYYtE6i8DWZ5kx35s2uQPi/cXaUiXgQ=; b=Vp5kqbATEHGH4mw9HI+4INYb82mtWw+2HS73rAo3MNyB/FnPeP29zLqLZGbCxxPUyO y+b8O+tQUKevLm3p6CJOA6h/ZwiQmJUm8LKxtco8UMWETYT3PNdlkbO37KzdK34QpDsO fHEl2isfRn0YrytxkU/z+tKkLhelm99awsyhhgSEnrblLJGUpHWd5eM6LttqJkgs5qlt LlX+47oLoR0LvML8mEJsMz0dip31J19A3QLRDImPC32RBqY2is7pQVDzG8wrjV9VYPHE udI+3+e3gRv51Rp06185TW9TQtZsGxa0KmjomixkCToZxx82dc6NN8KOf7jmbb7zkHFm rphQ== 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; bh=VN2QmRBHk/YVrYYtE6i8DWZ5kx35s2uQPi/cXaUiXgQ=; b=qMTL526H/Oi4SXQWuzMezUS3whCficdkejg4/USy7aCwbA44Y7HdFIlNDFRSlIifWO kZLR45iNNfLQJN4Wj7K4cqgDHRGj50fkJtCS1BDh+Z2Vb1/ZhQgQGJ7J07HH1ilBKdKs kb4VJYSwhLeT1R23v+SQiHQOWD9vEg4Vl68upwKCEgVG9qQIkm+pCdhpX10ehGPbeowD LJU4HbqWffHgSAVdPW60vOv1RGxJIIfpOZP2WHkJXOq/Ce4Sl6ALZtMSfuv0G8eHRMyF Jv9Cvsvb8DuSazyrX92hla4ePt1UVEH/PRQ3Nkfo9tkcN6F3OyJIIv37y0Pv6d6q/W8O Q11g== X-Gm-Message-State: AOAM531D8mUjTZiwcZA+PikcAYC45HBBxspPXkS6CY5BJM4hBXNg/pWI FCd7VCIoS9OjwY5WNrMQ5b9bUf4OYVT44s2zrHQ= X-Received: by 2002:a05:6402:518d:: with SMTP id q13mr31885055edd.313.1615836157714; Mon, 15 Mar 2021 12:22:37 -0700 (PDT) MIME-Version: 1.0 References: <1615303512-35058-1-git-send-email-xlpang@linux.alibaba.com> <793c884a-9d60-baaf-fab8-3e5f4a024124@suse.cz> In-Reply-To: From: Yang Shi Date: Mon, 15 Mar 2021 12:22:25 -0700 Message-ID: Subject: Re: [PATCH v3 0/4] mm/slub: Fix count_partial() problem To: Roman Gushchin Cc: Vlastimil Babka , Xunlei Pang , Christoph Lameter , Pekka Enberg , Konstantin Khlebnikov , David Rientjes , Matthew Wilcox , Shu Ming , Andrew Morton , Linux Kernel Mailing List , Linux MM , Wen Yang , James Wang , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 15, 2021 at 12:15 PM Roman Gushchin wrote: > > > On Mon, Mar 15, 2021 at 07:49:57PM +0100, Vlastimil Babka wrote: > > On 3/9/21 4:25 PM, Xunlei Pang wrote: > > > count_partial() can hold n->list_lock spinlock for quite long, which > > > makes much trouble to the system. This series eliminate this problem. > > > > Before I check the details, I have two high-level comments: > > > > - patch 1 introduces some counting scheme that patch 4 then changes, could we do > > this in one step to avoid the churn? > > > > - the series addresses the concern that spinlock is being held, but doesn't > > address the fact that counting partial per-node slabs is not nearly enough if we > > want accurate in /proc/slabinfo because there are also percpu > > slabs and per-cpu partial slabs, where we don't track the free objects at all. > > So after this series while the readers of /proc/slabinfo won't block the > > spinlock, they will get the same garbage data as before. So Christoph is not > > wrong to say that we can just report active_objs == num_objs and it won't > > actually break any ABI. > > At the same time somebody might actually want accurate object statistics at the > > expense of peak performance, and it would be nice to give them such option in > > SLUB. Right now we don't provide this accuracy even with CONFIG_SLUB_STATS, > > although that option provides many additional tuning stats, with additional > > overhead. > > So my proposal would be a new config for "accurate active objects" (or just tie > > it to CONFIG_SLUB_DEBUG?) that would extend the approach of percpu counters in > > patch 4 to all alloc/free, so that it includes percpu slabs. Without this config > > enabled, let's just report active_objs == num_objs. > > It sounds really good to me! The only thing, I'd avoid introducing a new option > and use CONFIG_SLUB_STATS instead. > > It seems like CONFIG_SLUB_DEBUG is a more popular option than CONFIG_SLUB_STATS. > CONFIG_SLUB_DEBUG is enabled on my Fedora workstation, CONFIG_SLUB_STATS is off. > I doubt an average user needs this data, so I'd go with CONFIG_SLUB_STATS. I think CONFIG_SLUB_DEBUG is enabled by default on most distros since it is supposed not incur too much overhead unless specific debug (i.e. red_zone) is turned on on demand. > > Thanks! > > > > > Vlastimil > > > > > v1->v2: > > > - Improved changelog and variable naming for PATCH 1~2. > > > - PATCH3 adds per-cpu counter to avoid performance regression > > > in concurrent __slab_free(). > > > > > > v2->v3: > > > - Changed "page->inuse" to the safe "new.inuse", etc. > > > - Used CONFIG_SLUB_DEBUG and CONFIG_SYSFS condition for new counters. > > > - atomic_long_t -> unsigned long > > > > > > [Testing] > > > There seems might be a little performance impact under extreme > > > __slab_free() concurrent calls according to my tests. > > > > > > On my 32-cpu 2-socket physical machine: > > > Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz > > > > > > 1) perf stat --null --repeat 10 -- hackbench 20 thread 20000 > > > > > > == original, no patched > > > Performance counter stats for 'hackbench 20 thread 20000' (10 runs): > > > > > > 24.536050899 seconds time elapsed ( +- 0.24% ) > > > > > > > > > Performance counter stats for 'hackbench 20 thread 20000' (10 runs): > > > > > > 24.588049142 seconds time elapsed ( +- 0.35% ) > > > > > > > > > == patched with patch1~4 > > > Performance counter stats for 'hackbench 20 thread 20000' (10 runs): > > > > > > 24.670892273 seconds time elapsed ( +- 0.29% ) > > > > > > > > > Performance counter stats for 'hackbench 20 thread 20000' (10 runs): > > > > > > 24.746755689 seconds time elapsed ( +- 0.21% ) > > > > > > > > > 2) perf stat --null --repeat 10 -- hackbench 32 thread 20000 > > > > > > == original, no patched > > > Performance counter stats for 'hackbench 32 thread 20000' (10 runs): > > > > > > 39.784911855 seconds time elapsed ( +- 0.14% ) > > > > > > Performance counter stats for 'hackbench 32 thread 20000' (10 runs): > > > > > > 39.868687608 seconds time elapsed ( +- 0.19% ) > > > > > > == patched with patch1~4 > > > Performance counter stats for 'hackbench 32 thread 20000' (10 runs): > > > > > > 39.681273015 seconds time elapsed ( +- 0.21% ) > > > > > > Performance counter stats for 'hackbench 32 thread 20000' (10 runs): > > > > > > 39.681238459 seconds time elapsed ( +- 0.09% ) > > > > > > > > > Xunlei Pang (4): > > > mm/slub: Introduce two counters for partial objects > > > mm/slub: Get rid of count_partial() > > > percpu: Export per_cpu_sum() > > > mm/slub: Use percpu partial free counter > > > > > > include/linux/percpu-defs.h | 10 ++++ > > > kernel/locking/percpu-rwsem.c | 10 ---- > > > mm/slab.h | 4 ++ > > > mm/slub.c | 120 +++++++++++++++++++++++++++++------------- > > > 4 files changed, 97 insertions(+), 47 deletions(-) > > > > > >