Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp947344pxb; Wed, 3 Mar 2021 22:07:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCGIfxLKLcr+ypN7yvE/XmxP4w4jDom+ohCV3S+ZaepNRorgpKiJxVpvGb1W4HqEPSre4D X-Received: by 2002:a50:f9c8:: with SMTP id a8mr2635124edq.270.1614838055773; Wed, 03 Mar 2021 22:07:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614838055; cv=none; d=google.com; s=arc-20160816; b=pgeLWbJuzojGUd6cGBRkR3ll3jBYZcJAnBJmjWvKWsHjeO9tb5f3QSadyCs2p4VTYm OkblwtrHehYNaMNkYX9Qs5OdwxlLjtnzRf7U0pABVRgyPdhONKucymZSxXVgRMLpQJVu hogoL2W525DlxIFq2WlQWamwsEHaHxLo0IDZCWufUj0NbqgIxSxclnYEq8p7JDsbQHxN Xo+NjItRMoIL/fhaQgdQ2wXm4guXCt5DQp7GmgBA81bozk1GoMzcp7SSj02l0JWF90Jn t8cTsUW6LaYanWme89DPL6I0QI6bRocUFWIXvapPjkHqRd9q+FfqKGamxs3TKHFMUMyB vivw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=Lp7osy/F3XSaUgdsZ46b8TA+4JJ596QYFd1MbEbs8h8=; b=QvHZu8FBEY6Pu3rl1pyl1OYbRlOF0kOuoYZ1hg3pvQ+7HBI3ZoT1VKaYjsZerkSge7 UEQYpXOBSt19+9mW9V/it7pnOcNi5G/uJCXlPja1vF92wGfJVRZ4w64uZIVZyQCsjvUg YvE6XatdmYkLntKJgsaE4XmMfclEBi8MWwOQaQero4ZplK32GgxfNbavijN1cUkeceqa NIpiURNfXhxqpgvJEhnlxJ9q0AiHuhTyrWLrqOXre/rs0B2lTABUfy1rMjXIL6tDu3lQ W+ERq7aAjsPYX3eHJZWmBAi93uD/Djz/CTRsUn4ak0enK8HvaiePTP0xbkpf5viSCL/d haqw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si4102447ejs.195.2021.03.03.22.07.13; Wed, 03 Mar 2021 22:07:35 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382526AbhCBJji (ORCPT + 99 others); Tue, 2 Mar 2021 04:39:38 -0500 Received: from vmi485042.contaboserver.net ([161.97.139.209]:38110 "EHLO gentwo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1837942AbhCBJPm (ORCPT ); Tue, 2 Mar 2021 04:15:42 -0500 X-Greylist: delayed 344 seconds by postgrey-1.27 at vger.kernel.org; Tue, 02 Mar 2021 04:15:41 EST Received: by gentwo.de (Postfix, from userid 1001) id C7556B00C98; Tue, 2 Mar 2021 10:14:53 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by gentwo.de (Postfix) with ESMTP id C5F01B00C5F; Tue, 2 Mar 2021 10:14:53 +0100 (CET) Date: Tue, 2 Mar 2021 10:14:53 +0100 (CET) From: Christoph Lameter To: Xunlei Pang cc: Vlastimil Babka , Wen Yang , Roman Gushchin , Pekka Enberg , Konstantin Khlebnikov , David Rientjes , linux-kernel@vger.kernel.org, "linux-mm@kvack.org" Subject: Re: [PATCH v2 3/3] mm/slub: Use percpu partial free counter In-Reply-To: <1597061872-58724-4-git-send-email-xlpang@linux.alibaba.com> Message-ID: References: <1597061872-58724-1-git-send-email-xlpang@linux.alibaba.com> <1597061872-58724-4-git-send-email-xlpang@linux.alibaba.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 10 Aug 2020, Xunlei Pang wrote: > > diff --git a/mm/slab.h b/mm/slab.h > index c85e2fa..a709a70 100644 > --- a/mm/slab.h > +++ b/mm/slab.h > @@ -616,7 +616,7 @@ struct kmem_cache_node { > #ifdef CONFIG_SLUB > unsigned long nr_partial; > struct list_head partial; > - atomic_long_t partial_free_objs; > + atomic_long_t __percpu *partial_free_objs; A percpu counter is never atomic. Just use unsigned long and use this_cpu operations for this thing. That should cut down further on the overhead. > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -1775,11 +1775,21 @@ static void discard_slab(struct kmem_cache *s, struct page *page) > /* > * Management of partially allocated slabs. > */ > +static inline long get_partial_free(struct kmem_cache_node *n) > +{ > + long nr = 0; > + int cpu; > + > + for_each_possible_cpu(cpu) > + nr += atomic_long_read(per_cpu_ptr(n->partial_free_objs, cpu)); this_cpu_read(*n->partial_free_objs) > static inline void > __update_partial_free(struct kmem_cache_node *n, long delta) > { > - atomic_long_add(delta, &n->partial_free_objs); > + atomic_long_add(delta, this_cpu_ptr(n->partial_free_objs)); this_cpu_add() and so on.