Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7757515rwl; Tue, 10 Jan 2023 05:09:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXs/uvEvCUiCqj3dS7gOSHk2s875JdE6HIxu/9zZ3wzeQHbGQITNTZcs9AO1Y4BBgj8DXb9M X-Received: by 2002:a17:906:a191:b0:7c0:d605:fe42 with SMTP id s17-20020a170906a19100b007c0d605fe42mr59873370ejy.18.1673356199062; Tue, 10 Jan 2023 05:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673356199; cv=none; d=google.com; s=arc-20160816; b=yrUoNjwQ1hwNUWlIxoq4eiVaAYo9Ybgfe+VLJVR6UBlfZxNENUZ+j4r25vryJpnOw3 93mexJPzx1YfaiJI9ytnQn8R/reDOjDvc93vZ/7s5RPYYV7Fxkb5MkJ7Mn+FxIHcTbOL coOu5Oue15vVOV9+d9VHgdzS+tFkuEbv6alXUjpYRJ4F8O07uaffrxAgzrtWj8cD82Xo bmtBRvk85aDz4ckLtKgHnWxI18WOJQbLIk5TU4mvODapWSxZ4jHMhq+h5XPrO7TWsA9s T6kJtVQRtVQ7Hi1F8FHTNjtRW0kn/AezUMngUe5wAzZhrwlmcwj4T4yaylqg2fSKTLKr Yc/g== 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=j3N+I1tOp5z58hWU20Y6grnAxYfUZf0yfp4ZZBGdHcc=; b=zqpcPtLSe5tBfa0dvOWjXaRE+1w0g4g37ZoASP27WbGwlMPoyu7r5m9g7ncBU2tEgC gSSrVoXIGBReKErmOBW2Qt4UVHWi49xY6K4YsJ6wKHLDExUD0AgQ7v/EVR7PxVieCopO l3V9aTrM8mKtajsOJBD1QpOucDXT4FEBHNGLz443mm8EEFeTdaEGgGG8+8Ri6+2/XlxK Hn5qvUYqhuJNKGIoO6EaxvPbNZIltlBFPizzG7uanU+FwyWNqhYlAcBbE0D87Vm9XvUa JjQjeZsAzbHl/FKxHjOA0YeP3zAWeFRjmJJdKObdC7AN7iiqVU5XHVzNTybP5am2BZBJ 6sVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MIvNCBCQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xa3-20020a170906fd8300b008552e7765cbsi2146079ejb.972.2023.01.10.05.09.46; Tue, 10 Jan 2023 05:09:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MIvNCBCQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232529AbjAJMOP (ORCPT + 53 others); Tue, 10 Jan 2023 07:14:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238356AbjAJMNg (ORCPT ); Tue, 10 Jan 2023 07:13:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF055689F for ; Tue, 10 Jan 2023 04:12:13 -0800 (PST) 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 AD73D6164B for ; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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!