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=-14.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,URIBL_BLOCKED, USER_AGENT_SANE_1 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 73776C4338F for ; Fri, 6 Aug 2021 07:50:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 08035610FD for ; Fri, 6 Aug 2021 07:50:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 08035610FD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 48A1A6B006C; Fri, 6 Aug 2021 03:50:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43A736B0071; Fri, 6 Aug 2021 03:50:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 302208D0001; Fri, 6 Aug 2021 03:50:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id 139E16B006C for ; Fri, 6 Aug 2021 03:50:06 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9EDD88249980 for ; Fri, 6 Aug 2021 07:50:05 +0000 (UTC) X-FDA: 78443882370.12.BF4C018 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf12.hostedemail.com (Postfix) with ESMTP id 16A711001533 for ; Fri, 6 Aug 2021 07:50:04 +0000 (UTC) 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 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=qq2EMQnh; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=BJmvFa6x; spf=pass (imf12.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 16A711001533 X-Stat-Signature: 6egupuwpb774sx373wogja1zp8g1nc6h X-HE-Tag: 1628236204-699884 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 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