Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1267147pxa; Thu, 20 Aug 2020 07:08:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6CRmTlfW366ktiIo9qgFRw1edBnVtEUuTR4STUnOr5PqxNAKEKGWgJteG3yTFwsj7EjQq X-Received: by 2002:a17:906:2a49:: with SMTP id k9mr3536669eje.117.1597932500906; Thu, 20 Aug 2020 07:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597932500; cv=none; d=google.com; s=arc-20160816; b=xNroO8VHzvVw3TFJb6CWiUT9zTZgD9aq6NHQ7V0A2winQk/JeFQJrXRiGVGnUP2tR4 PoxoJhteO2ZvdrXM1NRQX6sEIQUIwKxgTSEZp4wajqjQI/sp5LZ/XEI3QZ2/w3crYZSe l8hDR1mWInZ01/J80Z/kDxbsoYBDPd1rfRT3vXPRTHf2397/jC6TRN9L3M1kDLy/WU2B NdG0i+Ffmfw1vN7xXPLMBgzXvH/KYwE9LTXs68mKIB3VE1o1Ra2N824TOogK9derHJnC 81xFmpHYwYoBFAH2mmtEZCH+LATPQDYEU4Ud8b0cqkbUriurCvQmGW5lT1svWJwE02cz ffVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=27PMKVLomMz0Eib+Dl+VjSzpCmC6idgXY425VL4EzdY=; b=sRJj/Go+nEPM/0LKO83BpDvkQlGaNuwX1TBoxP0z6mnJebkic02fClQztH7HJLUDYu +L8W14esZVv7u4S2ZDdCN8RQ5uA3IGZ4htCpWD9L9wxShEfbJH0vVhZ6pRUPXVn4ou0+ HsA0/zY2sC/cF4oM5WHb8gJLGZqpis6oU392/dZ+0UagfmCQ2fGhEWdWhceKS0qHe/U7 jgKC9CHRmwDjFz1DXF4o6rWKAmdmM/zc7eIRdJ0hD+6AJrtcw4m6hlbH8t7AIEBvdDOk yMwU/hk8lDT/RjIStqLRgBMkAlLkH+0aKYqjyBxA7VnmiCZTDcODqOhJj46mFAeaJBE7 9hdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M2wcRAlV; 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 w5si1666498edv.438.2020.08.20.07.07.57; Thu, 20 Aug 2020 07:08:20 -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=M2wcRAlV; 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 S1728251AbgHTOHG (ORCPT + 99 others); Thu, 20 Aug 2020 10:07:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731256AbgHTN6u (ORCPT ); Thu, 20 Aug 2020 09:58:50 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7F8AC061385 for ; Thu, 20 Aug 2020 06:58:49 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id k12so1534370otr.1 for ; Thu, 20 Aug 2020 06:58:49 -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=27PMKVLomMz0Eib+Dl+VjSzpCmC6idgXY425VL4EzdY=; b=M2wcRAlVkK9M9njr7QiaUuZJLX5lZmAkOrlqu7uqeuzHSvjoRX/QK6sLcI41BdZHqX adfeZZdTjN5tKoJ8S9NL8OLNtJTBmDfHim9j4PE4/4m4g3DTi03Eeoz4wOLJSwN46KSY U/Qq0YxnCNPqTAv16cjFqAKIiyzcuDSHWkPQHgSTehmzEE8X3w3oknQU+24dH4k0u75W 5d6X8YqY27jV4bi+qKzfZz468u0fCCaMcTsGBKBuI2xJ844d/bmOb9GbxjMnLrZcVgIo ORP/W0k0Qc20HotT+GqHnoxIGBtzpC6Ygx/6nyrFTOMlpaJNkyaKlsHoSpBPxoF12ba3 eNHw== 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=27PMKVLomMz0Eib+Dl+VjSzpCmC6idgXY425VL4EzdY=; b=V1eDyMnAgY1AzjIZM8leL9fq5kzoCZHUG9jgqr/2hR+3molWjM3q5Bi7wqI9Nqc8av kNE00wVRDVXj7AtCDOmsI3lfq5EExGsxpSIkyIDMcc3X4EijxXGZAVnKuSgNY3h3/Zb1 wL2XUUOJbDhQCFFP3PpL/l83h8ZxnvP6JuNgOktBkbgBpc/xnOxRMpRCtIzylHY+K5lk alLg3lVAC+7jx5FBrucmITCEg4j+gKmmRZxmA4GJLZ8yp0TfSSAJb+8xughXGULMZyWR LG4AcrzxOVvdjSKJYxv6p+rIJwIxyw4QF7WMpHVQfR3lsPKfJzIKoB0aSC/WfEUPMBPT 6H1g== X-Gm-Message-State: AOAM531FdnfTJwnvsL7+0nq78myUHYQB1h+cX+Nq5cBym1vpisaybNco JHrqlC4M7qaOF9a+H8bFLH++D4dh3IO39Y0sZU8A9Va/MIQk0g== X-Received: by 2002:a9d:20c4:: with SMTP id x62mr2027505ota.99.1597931929160; Thu, 20 Aug 2020 06:58:49 -0700 (PDT) MIME-Version: 1.0 References: <1593678728-128358-1-git-send-email-xlpang@linux.alibaba.com> In-Reply-To: From: Pekka Enberg Date: Thu, 20 Aug 2020 16:58:31 +0300 Message-ID: Subject: Re: [PATCH 1/2] mm/slub: Introduce two counters for the partial objects To: Christopher Lameter Cc: Vlastimil Babka , Xunlei Pang , Andrew Morton , Wen Yang , Yang Shi , Roman Gushchin , "linux-mm@kvack.org" , LKML , Konstantin Khlebnikov , David Rientjes Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christopher, On Tue, Aug 11, 2020 at 3:52 PM Christopher Lameter wrote: > > On Fri, 7 Aug 2020, Pekka Enberg wrote: > > > Why do you consider this to be a fast path? This is all partial list > > accounting when we allocate/deallocate a slab, no? Just like > > ___slab_alloc() says, I assumed this to be the slow path... What am I > > missing? > > I thought these were per object counters? If you just want to count the > number of slabs then you do not need the lock at all. We already have a > counter for the number of slabs. The patch attempts to speed up count_partial(), which holds on to the "n->list_lock" (with IRQs off) for the whole duration it takes to walk the partial slab list: spin_lock_irqsave(&n->list_lock, flags); list_for_each_entry(page, &n->partial, slab_list) x += get_count(page); spin_unlock_irqrestore(&n->list_lock, flags); It's counting the number of *objects*, but the counters are only updated in bulk when we add/remove a slab to/from the partial list. The counter updates are therefore *not* in the fast-path AFAICT. Xunlei, please correct me if I'm reading your patches wrong. On Tue, Aug 11, 2020 at 3:52 PM Christopher Lameter wrote: > > No objections to alternative fixes, of course, but wrapping the > > counters under CONFIG_DEBUG seems like just hiding the actual issue... > > CONFIG_DEBUG is on by default. It just compiles in the debug code and > disables it so we can enable it with a kernel boot option. This is because > we have had numerous issues in the past with "production" kernels that > could not be recompiled with debug options. So just running the prod > kernel with another option will allow you to find hard to debug issues in > a full scale producton deployment with potentially proprietary modules > etc. Yeah, it's been too long since I last looked at the code and did not realize even count_partial() is wrapped in CONFIG_DEBUG. So by all means, let's also wrap the counters with that too. - Pekka