Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1146494pxb; Thu, 4 Mar 2021 04:41:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCqRzVGruOmkSVONWJtOPkOuiE3Lf/GsJOn4yYALoEazQHDLBkiHmAwfbBErlo/xyXudMV X-Received: by 2002:a05:6402:1398:: with SMTP id b24mr3974046edv.108.1614861692537; Thu, 04 Mar 2021 04:41:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614861692; cv=none; d=google.com; s=arc-20160816; b=aRcq7CUd91Ov5T5KLlLHvovIJZ/5taCIFccp2xojMlYxMMPrjB5joBqMQzXWoYj5Uz 6rglr6/iNieZNecxmYI7Oi2x0bS3uzkRqRvVBhz6Qt+w0uLvSQaln4Y6gxDlkueNJwzl iDwUI6tHg42XIp02uZ7X3/vBF4P+4lJ3FNQXBQgcCMzsZocZJIFcndJi0727mRuV5AeZ sE7Ie8Yos6jjhO8JaRHWjhvm3jD5uoPUWEjbUu+Cyz0cZw3Vhp73oV0+KjW2c1RoG28F fxhlGX4DYS9uclXp2nMaUlB1LL1xiuqyJu2PYeGR3Mw/Ilqa2BRbo223tP8Jz97H7mtt 9I2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=w7rnAtm+5rmUMrt1OegFvCAzCtgfl80a+yX/UPaOyPY=; b=mWhWF4uFviVS7auYyhUci7z6fS5+//EbpHcqabkTUrnU26zcyG4zCmT2zF1c2nXSBb oNg9y2I+6JW63tfqWlHKH5JEii8u4nMPVK/xJmH7dHs7xSc5JH7H3IKcXnYQhf7NavyP mCtl1yJU/PwGZpXqQ4XNDuo4fqlX0In7fKGZNA0ItRHftCkwnmjJhF/OGViml7yFPO9K dUde4c1mCMEaeJq2oeksirEwj7JI1wbMB9xs963dwdP0RtTEeXdtiiINp1Ug5P7HUDQn 1noLb37YX5hyxkqN4p6hln4WeW63YZammqENTknOZrhT3UhbhS9NLu9ucFhlpsf78Pz8 r6Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HFX3Ree+; 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 w14si14444249edu.225.2021.03.04.04.41.09; Thu, 04 Mar 2021 04:41:32 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HFX3Ree+; 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 S231497AbhCCX7r (ORCPT + 99 others); Wed, 3 Mar 2021 18:59:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245757AbhCCTmA (ORCPT ); Wed, 3 Mar 2021 14:42:00 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE66C06175F for ; Wed, 3 Mar 2021 11:30:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=w7rnAtm+5rmUMrt1OegFvCAzCtgfl80a+yX/UPaOyPY=; b=HFX3Ree+HgwGP9YppDyjBu+56k LUsFOu01L/T5XS5UmatceiCZxATCw60R2G5ciblJbG1Nt6NG9OIW1g0ASfgMWGZ8RFKDy/XwgOkxB tbN+9LR01DA6SsvlLGy4bnfMUf+NQTVjBWS4TbE92TwtphqbllbdPeArDTgprPR/e4mHQCXO2a+vf GC5wSK93cFyubBVDc9pQf+ecQtkWKhDUyidXRh9iW1Ac5EtoNGoYjpFUEGCIEUPCDaaLqRyADXBXp jN6aag39uFyQQmm9DULLIHHAXVPTnOczhxLv/b173nGPF+STy9BCHzIYxwEx0yGWy83yy6XUZXPbU SMr9HIEg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lHXCg-003uht-L8; Wed, 03 Mar 2021 19:30:39 +0000 Date: Wed, 3 Mar 2021 19:30:38 +0000 From: Matthew Wilcox To: Christoph Lameter Cc: Xunlei Pang , 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 Message-ID: <20210303193038.GE2723601@casper.infradead.org> References: <1597061872-58724-1-git-send-email-xlpang@linux.alibaba.com> <1597061872-58724-4-git-send-email-xlpang@linux.alibaba.com> <20210303142612.GC2723601@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 03, 2021 at 08:15:58PM +0100, Christoph Lameter wrote: > On Wed, 3 Mar 2021, Matthew Wilcox wrote: > > > On Tue, Mar 02, 2021 at 10:14:53AM +0100, Christoph Lameter wrote: > > > On Mon, 10 Aug 2020, Xunlei Pang wrote: > > > > - 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. > > > > What about allocations from interrupt context? Should this be a local_t > > instead? > > Can this be allocated in an interrupt context? > > And I am not sure how local_t relates to that? Percpu counters can be used > in an interrupt context without the overhead of the address calculations > that are required by a local_t. As I understand the patch, this counts the number of partially free slabs. So if we start to free an object from a completely full slab in process context, as "load x, add one to x, store x" and take an interrupt between loading x and adding one to x, that interrupt handler might free a different object from another completely full slab. that would also load the same x, add one to it and store x, but then the process context would add one to the old x, overwriting the updated value from interrupt context. it's not the likeliest of races, and i don't know how important it is that these counters remain accurate. but using a local_t instead of a percpu long would fix the problem. i don't know why you think that a local_t needs "address calculations". perhaps you've misremembered what a local_t is?