Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp434113pxt; Fri, 6 Aug 2021 05:43:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEyqg+5SIO45ZT/eJzsxyd5E3bcpfsV3NHF6cjQPCxDnM5tZaST2wHowEFNm2LXYx4ur1M X-Received: by 2002:a92:da4a:: with SMTP id p10mr120129ilq.290.1628253829997; Fri, 06 Aug 2021 05:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628253829; cv=none; d=google.com; s=arc-20160816; b=B3LTjhTzS4Yp43HTWlFypIPCUWaESFUmeBaz+1VgOF3W6god7ghZXr2BD8C2K9JPrz ABl8N195mFKEvI+W/kKz8I6jRI8qS+Ul37FA+lg6u9oXbFZOncHGzFL45c9/x9m2Gl5S QGVHl/G6w4ltIWHhc+LoHeZBJDJE81t+MOGLpjQWcnmhZdzzc3WHTuTgryeUAY7bL1R1 MAfwVPqaAeOgQLP6jyHTW5KyM6s3ldNJBCH/sm6d9yacz/IkVNCFUcjox4mtBLKl55Qt WHSMdiVkeYy44wXTWR5Gxipz01fj88gnFSkjQ0m8fCRWaXmrxwhguML9k08BihfKHfke mOhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature; bh=6+laCi4KxR5UVLdNnL6puwvywYfdNwxG0t+wvdhSYH8=; b=REquHYV73kENN/NhRbHvMuKJfQ0Km2OuXIJSRK2Rt37AOUvxnNErirwfe4B4OzVNdg 4E3qRlY31QtJfBH74YsA3rnidqIynwS0w1REwgG15MsDtzeNnXcLfdFt1i7Nbjue7JmU VTA8p57qrvOsmfxyqRkRHi634aA4RJBsil1lSJ9iD9ZDpIeRy3OHuBaDxNKCoLG6S+Sg 8r60PtgX4Y6kLC0QkxK/ql8TVRiuPKCf7epfPV+8qTjUlVrZbzleBayiDaFa1joQLPP5 W19WSAIvUmNRvvRlKHI3nQ3BR1ZsBPXNt5AoqwQL9Az+S0Lh/uk0iM8xbv8QkJRCISxV vstw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qq2EMQnh; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 z18si8132463jan.6.2021.08.06.05.43.35; Fri, 06 Aug 2021 05:43:49 -0700 (PDT) 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=@suse.cz header.s=susede2_rsa header.b=qq2EMQnh; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 S242827AbhHFHu2 (ORCPT + 99 others); Fri, 6 Aug 2021 03:50:28 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:35670 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241930AbhHFHuU (ORCPT ); Fri, 6 Aug 2021 03:50:20 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 12FA81FEB1; Fri, 6 Aug 2021 07:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628236204; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6+laCi4KxR5UVLdNnL6puwvywYfdNwxG0t+wvdhSYH8=; b=qq2EMQnh29L5obPz8YFw/w1f8NhcK8RC4DwMtK0HU8cUBRohMfnkNeiVcv5rt0cdHaBmP8 c/U03ADuVgVibyy9YrhilRBvLVw7jaJyTq3hb0vxY/dsT086RpXqHXfk/l2Qx6iMuspEGo C/pyta0kFCzohOfDumCANsYItxZZOuE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628236204; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6+laCi4KxR5UVLdNnL6puwvywYfdNwxG0t+wvdhSYH8=; b=BJmvFa6xukjL3UBb1FBe2vxD0SyqyqGCPtB4dNBZu6K3we9h1ZTZTHiUhmUO6tQ8w1N/tT w7e737fKM3XzR5AQ== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id E85C213990; Fri, 6 Aug 2021 07:50:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id N88gOKvpDGEcGgAAGKfGzw (envelope-from ); Fri, 06 Aug 2021 07:50:03 +0000 Subject: Re: [PATCH 1/1] mm/vmstat: Protect per cpu variables with preempt disable on RT To: Andrew Morton , Mel Gorman Cc: Thomas Gleixner , Ingo Molnar , Hugh Dickins , Linux-MM , Linux-RT-Users , LKML References: <20210805160019.1137-1-mgorman@techsingularity.net> <20210805160019.1137-2-mgorman@techsingularity.net> <20210805162206.664dfc8c090f2be5ea313d57@linux-foundation.org> From: Vlastimil Babka Message-ID: Date: Fri, 6 Aug 2021 09:50:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210805162206.664dfc8c090f2be5ea313d57@linux-foundation.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/6/21 1:22 AM, Andrew Morton wrote: > 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(); > } Yeah v1 introduced similar more generic ones in include/linux/preempt.h and Thomas didn't like that. I guess it would be more acceptable when confined to mm/vmstat.c