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 X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 ED4A1C432BE for ; Thu, 5 Aug 2021 23:22:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 41B1B61132 for ; Thu, 5 Aug 2021 23:22:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 41B1B61132 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 280876B006C; Thu, 5 Aug 2021 19:22:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 231A56B0071; Thu, 5 Aug 2021 19:22:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 146386B0072; Thu, 5 Aug 2021 19:22:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id EBD506B006C for ; Thu, 5 Aug 2021 19:22:08 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8F4FA127A4 for ; Thu, 5 Aug 2021 23:22:08 +0000 (UTC) X-FDA: 78442602336.40.E63EE76 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf22.hostedemail.com (Postfix) with ESMTP id 384AF373D for ; Thu, 5 Aug 2021 23:22:08 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 09D3060EB9; Thu, 5 Aug 2021 23:22:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1628205727; bh=i33xhaeVpXGV2BhPzbhlBwQZn8O01SRCEx1xg2D/ogc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PTOpokADg1joo1BVq/LCyTP9Dfnys2JPYFddBTo/oM2s9Oq8QuhsyXA1enMA2eGac 0x4GIL0nALbQznW9/AXuBTYRAWOBBTmZ1dxdvKyj5e0dgMs+brROUIjE84aqWvlSR8 Dddsnpxxa3os65Jvg4JFsDxb4S8YyKSRDuS2cUWc= Date: Thu, 5 Aug 2021 16:22:06 -0700 From: Andrew Morton To: Mel Gorman Cc: Thomas Gleixner , Ingo Molnar , Vlastimil Babka , Hugh Dickins , Linux-MM , Linux-RT-Users , LKML Subject: Re: [PATCH 1/1] mm/vmstat: Protect per cpu variables with preempt disable on RT Message-Id: <20210805162206.664dfc8c090f2be5ea313d57@linux-foundation.org> In-Reply-To: <20210805160019.1137-2-mgorman@techsingularity.net> References: <20210805160019.1137-1-mgorman@techsingularity.net> <20210805160019.1137-2-mgorman@techsingularity.net> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=PTOpokAD; spf=pass (imf22.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 384AF373D X-Stat-Signature: i5zype8u7wp3ce7d1dnmj33igjdfqmxu X-HE-Tag: 1628205728-789779 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 Thu, 5 Aug 2021 17:00:19 +0100 Mel Gorman wrote: > From: Ingo Molnar > > Disable preemption on -RT for the vmstat code. On vanila the code runs > in IRQ-off regions while on -RT it may not when stats are updated under > a local_lock. "preempt_disable" ensures that the same resources is not > updated in parallel due to preemption. > > This patch differs from the preempt-rt version where __count_vm_event and > __count_vm_events are also protected. The counters are explicitly "allowed > to be to be racy" so there is no need to protect them from preemption. Only > the accurate page stats that are updated by a read-modify-write need > protection. This patch also differs in that a preempt_[en|dis]able_rt > helper is not used. As vmstat is the only user of the helper, it was > suggested that it be open-coded in vmstat.c instead of risking the helper > being used in unnecessary contexts. > > ... > > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -319,6 +319,16 @@ void __mod_zone_page_state(struct zone *zone, enum zone_stat_item item, > long x; > long t; > > + /* > + * Accurate vmstat updates require a RMW. On !PREEMPT_RT kernels, > + * atomicity is provided by IRQs being disabled -- either explicitly > + * or via local_lock_irq. On PREEMPT_RT, local_lock_irq only disables > + * CPU migrations and preemption potentially corrupts a counter so > + * disable preemption. > + */ > + if (IS_ENABLED(CONFIG_PREEMPT_RT)) > + preempt_disable(); This is so obvious I expect it has been discussed, but... why not static inline void preempt_disable_if_rt(void) { if (IS_ENABLED(CONFIG_PREEMPT_RT)) preempt_disable(); } ?