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=-5.2 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 E6CFAC432BE for ; Wed, 4 Aug 2021 13:42:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4F5FE60F6F for ; Wed, 4 Aug 2021 13:42:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4F5FE60F6F 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 BAE426B0071; Wed, 4 Aug 2021 09:42:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5E5B8D0001; Wed, 4 Aug 2021 09:42:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4D606B0073; Wed, 4 Aug 2021 09:42:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 896716B0071 for ; Wed, 4 Aug 2021 09:42:28 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2FDF918206D51 for ; Wed, 4 Aug 2021 13:42:28 +0000 (UTC) X-FDA: 78437512776.11.CBD9BEF Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf09.hostedemail.com (Postfix) with ESMTP id 91DD1300B3A4 for ; Wed, 4 Aug 2021 13:42:27 +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 133881FDF0; Wed, 4 Aug 2021 13:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628084546; 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=cd6QFPd1A0Bmx9XXWp5vLXMioX3R+S1I/iAZz0+5Ls4=; b=NdOwFa031p1tD5wGcSqoW6lXbr5pHOZfdIZigz9+bZarnzU/vrf3eEFouH2Ba9OW1HbnOY r8DG1aqp/N3YT+EbvHuQWY2XJSiC1rxW3IXzezRKHXFaq8aviX/KmS1xZG0dVXkCXMFBeZ BI3stuXS2SyOB4gxGKD2DsYAQzpV14o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628084546; 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=cd6QFPd1A0Bmx9XXWp5vLXMioX3R+S1I/iAZz0+5Ls4=; b=y05y+n1nHBWU82vDBKoaBOVztk7mSZqow5Jwmq0SvZEKxZ1SaGo8UymlvIFU4odwaBcbWW MCL6IfvwIF+BeuDQ== 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 E150313942; Wed, 4 Aug 2021 13:42:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id dALvNUGZCmFgQQAAGKfGzw (envelope-from ); Wed, 04 Aug 2021 13:42:25 +0000 To: Mel Gorman , Thomas Gleixner Cc: Andrew Morton , Ingo Molnar , Hugh Dickins , Linux-MM , Linux-RT-Users , LKML , Peter Zijlstra References: <20210723100034.13353-1-mgorman@techsingularity.net> <20210723100034.13353-3-mgorman@techsingularity.net> <87czqu2iew.ffs@tglx> <20210804095425.GA6464@techsingularity.net> From: Vlastimil Babka Subject: Re: [PATCH 2/2] mm/vmstat: Protect per cpu variables with preempt disable on RT Message-ID: <91b2f893-eb6a-d91d-3769-baba8601b0f6@suse.cz> Date: Wed, 4 Aug 2021 15:42:25 +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: <20210804095425.GA6464@techsingularity.net> Content-Type: text/plain; charset=iso-8859-15 Content-Language: en-US Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=NdOwFa03; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=y05y+n1n; dmarc=none; spf=pass (imf09.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Stat-Signature: qzga66yqfxxorpb357h536e4bg5eu5ox X-Rspamd-Queue-Id: 91DD1300B3A4 X-Rspamd-Server: rspam01 X-HE-Tag: 1628084547-880590 Content-Transfer-Encoding: quoted-printable 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/4/21 11:54 AM, Mel Gorman wrote: > On Wed, Aug 04, 2021 at 01:54:47AM +0200, Thomas Gleixner wrote: >>=20 >> so in vmstat.c there is this magic comment: >> * For use when we know that interrupts are disabled >> * or when we know that preemption is disabled and that >> * particular counter cannot be updated from interrupt context= . >> how can I know which counters need what? >> I don't think there's a list, one would have to check on = counter to counter basis :/=20 >> and of course there is nothing which validates that, right? >> exactly >>=20 >=20 > While I'm not "mm_expert", I agree with his/her statements. Phew, since you do, I can now disclose it was me. > Each counter > would need to be audited and two question are asked >=20 > o If this counter is inaccurate, does anything break? > o If this counter is inaccurate, does it both increment and decrement > allowing the possibility it goes negative? >=20 > The decision on that is looking at the counter and seeing if any > functional decision is made based on its value. So two examples; >=20 > NR_VMSCAN_IMMEDIATE is a node-based counter that only every > increments and is reported to userspace. No kernel code makes > any decision based on its value. Therefore it's likely safe to > move to numa_stat_item instead. >=20 > Action: move it >=20 > WORKINGSET_ACTIVATE_FILE is a node-based counter that is used to > determine if a mem cgroup is potentially congested by looking at > the ratio of cgroup to node refault rates as well as deciding if > LRU file pages should be deactivate. If that value drifts, the > ratios are miscalculated and could lead to functional oddities > and therefore must be accurate. >=20 > Action: leave it alone >=20 > I guess it could be further split into state that must be accurate from > IRQ and non-IRQ contexts but that probably would be very fragile and > offer limited value. >=20 >> Brilliant stuff which prevents you to do any validation on this. Over >> the years there have been several issues where callers had to be fixed >> by analysing bug reports instead of having a proper instrumentation in >> that code which would have told the developer that he got it wrong. >>=20 >=20 > I'm not sure it could be validated at build-time but I'm just back from > holiday and may be lacking imagination. The idea was not build-time, but runtime (hidden behind lockdep, VM_DEBUG= or whatnot), i.e.: what that code needs is switch(item) { case foo1: case foo= 2: lockdep_assert_irqs_disabled(); break; case bar1: case bar2: lockdep_assert_preempt_disabled(); lockdep_assert_no_in_irq(); break; } o= r something along those lines >> Of course on RT kernels the preempt_disable_rt() will serialize >> everything correctly, but as we have learned over the years just >> slapping _if_rt() or if_not_rt() variants of things around is most of >> the time papering over the underlying problem of badly defined >> protection scopes. Let's not proliferate that. As I said in the above >> IRC conversation: >>=20 >> I fundamentally hate this preempt_disable_rt() muck >>=20 >=20 > The issue is that even if this was properly audited and the inaccurate > and accurate counters were in the proper enums using the correct APIs, = it > would still be necessary to protect the accurate counters from updates = from > IRQ context. Hence, as I write this, I don't think preempt_[dis|en]able= _rt > would go away and that is why I didn't continue with the series to brea= k > out "accurate" stats >=20