From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D10EC46467 for ; Tue, 10 Jan 2023 12:12:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C43D08E0002; Tue, 10 Jan 2023 07:12:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF4268E0001; Tue, 10 Jan 2023 07:12:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABBE28E0002; Tue, 10 Jan 2023 07:12:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9BF318E0001 for ; Tue, 10 Jan 2023 07:12:15 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7175B12127D for ; Tue, 10 Jan 2023 12:12:15 +0000 (UTC) X-FDA: 80338776630.12.7ABD878 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id CDEEC180011 for ; Tue, 10 Jan 2023 12:12:13 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MIvNCBCQ; spf=pass (imf24.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673352733; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=j3N+I1tOp5z58hWU20Y6grnAxYfUZf0yfp4ZZBGdHcc=; b=ckhUIkpHJ5J/wp7HxLn7HOiTgWjecS8zAwUGKMj3eySPmqCX4hTvyQGgQclcpSRgwDq/hK nNlzqve6o1QiYVprE8phdv122OZ85gJunoVWDMmPKcKAdvfXe9x/GUzs/ZWJ1VX8o0Rwlt YHm7y13ISXHXH6qIW+XR1Dig81PKhJ0= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MIvNCBCQ; spf=pass (imf24.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673352733; a=rsa-sha256; cv=none; b=jUANVokg9zqZa+ZpBOfZc0Vg4cMwk4iaCNInR4kAWaToI1mNMKq9bQKt+BQJluGiwvhale MAfsewWlGrGV4r0OWlQBTR+hzkLv60ecqRHfZRZRKH5E/eZRi51COx6aL7rnkfsclDgCcI 8uhfhU+e946FPyrNDlBxPmUvF0NKnlE= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A902B61645; Tue, 10 Jan 2023 12:12:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB573C433D2; Tue, 10 Jan 2023 12:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673352732; bh=IwWkvSRf3Gwtk3/2fKB8W1LEqyUfjSb4cgN/1aunrQw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MIvNCBCQeSJAb0ufgFn2X7p6SO0YRwIfLXnoYtIe+CernyIifOQT6NpABFLGqn+xR UyPXcKmi1oX7mrFO/7JBEkKgtqgfxrQ1Dxk98crXX98ZkfwpEvS+OTSpaO60+8Yu9e 8D6EKNs2bXFEyTWA2iZipQIb8vbHt7UXjWm2+fm3YeKeOcRSwgYdwQK0bmT8du/QFS 4bNqzXOTjKc2hf94w/WzSP3hZ06fCMOKgPWETpkDhoJsBz5Ntnlh8eba4KYprcw/MG p78LxzkJT22wgQftVlJGdCChOy3VQ/TyJ6ChLTOw6OKODOGYZM9Tbv6NhWvmNheteq Ajox8DEAuPslg== Date: Tue, 10 Jan 2023 13:12:09 +0100 From: Frederic Weisbecker To: Christoph Lameter Cc: Marcelo Tosatti , atomlin@atomlin.com, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, pauld@redhat.com, neelx@redhat.com, oleksandr@natalenko.name, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v13 1/6] mm/vmstat: Add CPU-specific variable to track a vmstat discrepancy Message-ID: References: <20230105125218.031928326@redhat.com> <20230105125248.772766288@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: CDEEC180011 X-Stat-Signature: rxdtprthze9a5k86t1wc3rnbhgxkesn7 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1673352733-490637 X-HE-Meta: U2FsdGVkX194HvbZh1LBTRDZhoG2gORG9VtpfhSIpIbZuzEe47dND0X2qamXDv5o54vT7lNEHYkCAMMmmKqoKNCVyj2dUsKfwP9pkup7sl/xgaapWvhPDVdOdcep1O7EOE+aA5x3e9lbgoHsmlbeWmd0gXg6eyc64oWfCINK+mpZnxYLE0vozaVceSG/mDFrw5mIjYjD7FKfjiTxniOeeENqqPl3Ctv5E5NTiT5DVyn/LKqyQ59j6yh6HsjAttV0MmtyQ2fjAf51/xXx82WbGmGNWn4Ci525ETAVWEo559fRJsQ2DySOVdDdx3Ni2/RwB7yog8DN0TN9pfkLWa3vEilzc2RML4GgbxL3/UNMjKhFDECDZr96STBsweb3Nukavv3nNV6IKzneSWdle3leC2WdyK7tstdd/iOXO1PPjWCnOjkhOR/NTfmb7sgGN6J3UUp+PJmW/YmLXtsmhgnooa3SsfVNfIRToGgrycSmjEIQZWVd4qqJTH+vjTfW8XIaxuMy+6AZ+xmoD4tn6KVyPUoR7FdjWeGzr2/EktaQIB2dSDW3zcmNX9pqTJAmW9iaOBABbUPG0/RqN5qv3SeuE51KFKg6e7QjRt+tweFddIsUQyoy1zh+YJUhoxBDR2//4lJtggwmAZvw4OKfKmR3s/0wKoFkrnR64uCOJa1IExvppm64Dtba3Iu/ANfAeTiHgoO0t8aFzzPLAg/iycXVCE7gYptyVO3wJjXkyEf0NWajAb+cdXbYIvmLVHka1DOoWMe5RuOWQ+o8LdbPBi5vkOML8xNVJkBg6/KVOpHA5/GZq/Xe9tXuVMWL1oqFWgfuMrlqeOtcTxdt3Tdaty9xE9jBBT9ovG8aH8TOIIlyp1a9MB2Q/QN6exsSSIdlKapk1YwR+rmd4kgILtciKkUjfZt5EjXCMb1XUlKqTja/YyJ/szBZtsW0fqOtxQenkVDbNfuYpAa4+AwawazA9oe H2hTAEhs X6o/mdka3EH1xI7Wf4E9/h6/2CGwWWjYuRhNc 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 Tue, Jan 10, 2023 at 12:58:32PM +0100, Christoph Lameter wrote: > On Thu, 5 Jan 2023, Marcelo Tosatti wrote: > > > +static inline void vmstat_mark_dirty(void) > > +{ > > + this_cpu_write(vmstat_dirty, true); > > +} > > this_cpu_write() is intended for an per cpu atomic context. You are not > using it in that way. The processor may have changed before or after and > thus vmstat_dirty for another CPU may have been marked dirty. > > I guess this would have to be called __vmstat_mark_dirty() and be using > __this_cpu_write(*) with a requirement that preemption be disabled before > using this function. You're right. So this patchset also arranges for these vmstat functions to be called with preemption disabled. I'm converting the this_cpu operations to __this_cpu versions to make sure of that. And I believe the __this_cpu WARN if preemptible(). > > > +static inline void vmstat_clear_dirty(void) > > +{ > > + this_cpu_write(vmstat_dirty, false); > > +} > > Same > > > +static inline bool is_vmstat_dirty(void) > > +{ > > + return this_cpu_read(vmstat_dirty); > > +} > > This function would only work correctly if preemption is disabled. > Otherwise the processor may change. Indeed that should apply as __this_cpu_read() as well. Thanks!