Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17153C433DB for ; Wed, 3 Mar 2021 20:32:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9BE1D64F02 for ; Wed, 3 Mar 2021 20:32:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BE1D64F02 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3101E6B0005; Wed, 3 Mar 2021 15:32:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E6476B0006; Wed, 3 Mar 2021 15:32:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D5786B0007; Wed, 3 Mar 2021 15:32:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 044566B0005 for ; Wed, 3 Mar 2021 15:32:49 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A65A11836F631 for ; Wed, 3 Mar 2021 20:32:49 +0000 (UTC) X-FDA: 77879711658.08.476C8E5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 1BEBDA0009FB for ; Wed, 3 Mar 2021 20:32:32 +0000 (UTC) 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=gndyAcqrFEb63lWZfXawPqTaD/MPoQSVtS2l/6X7nOE=; b=Hy0MCL/pcPG630Jq37Pi6sfRtV 0ZAZLuuOX51OLePqKr3e/vp3gLmwNjaSSyjBhstskI8wB2Xz9gAbeuYufynBjW8nKF2dWyA42V0/K EZOokb4u7ILkr0zMR0LTKoqMo9iFxSe4A0VVeHFTGuhUTKu96Z8uzBtGfOftzb4EI5Lm8AtF2OIob nnqQYbFhHVoiNEVnhdMxgKaXkZ/NnyIclhMEny94+NY67y/7QczxPlh6+e2/iimRss70Po2CrPDef jJSC41+VTZjuCmP7RPwpxxIv2elYgG565Q0CV0hkbg3DsJktqi+9PzTcoYaNzZ/lPHpEiBRClJLhn /BEY3sVA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lHXvN-0043UN-GD; Wed, 03 Mar 2021 20:16:52 +0000 Date: Wed, 3 Mar 2021 20:16:49 +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: <20210303201649.GF2723601@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> <20210303193038.GE2723601@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: ttdrwtgnqorrnwixyds1dhafkffga5uz X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1BEBDA0009FB Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614803552-639721 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Mar 03, 2021 at 08:55:48PM +0100, Christoph Lameter wrote: > On Wed, 3 Mar 2021, Matthew Wilcox wrote: > > > > 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. > > this_cpu operations are "atomic" vs. preemption but on some platforms not > vs interrupts. That could be an issue in kmem_cache_free(). This would > need a modification to the relevant this_cpu ops so that interrupts are > disabled on those platforms. Hmmmm ... re-reading the documentation, it says that this_cpu_x is atomic against interrupts: These operations can be used without worrying about preemption and interrupts:: [...] this_cpu_add(pcp, val) this_cpu_inc(pcp) ...