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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7F32C433EF for ; Thu, 24 Feb 2022 12:38:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DC0C8D0002; Thu, 24 Feb 2022 07:38:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 58D8C8D0001; Thu, 24 Feb 2022 07:38:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 454268D0002; Thu, 24 Feb 2022 07:38:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 379B08D0001 for ; Thu, 24 Feb 2022 07:38:37 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0C76C23675 for ; Thu, 24 Feb 2022 12:38:37 +0000 (UTC) X-FDA: 79177627074.13.9487A65 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf31.hostedemail.com (Postfix) with ESMTP id BDCA220004 for ; Thu, 24 Feb 2022 12:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645706289; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YRjb58oU+mffN2OBfWfcPKcr9rxdbyZA6C2HyvymPc4=; b=S8om/3tAQn2K5Yycgf27OBmH64VPa25/5Z3QDOoz3NsWI1XA9d4ehKAVNaWhUUjqyCDMYF cZ1t6YpSm+s9EHWU+UZGGjb1U3DnnJaFU6O8muZ0npY0DX8GCcQbwLhrcbP10CO94DbY8G xRi/Cs4mMeBf4ur3EqwWE9cwc7r90U4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-79-ULOiTRekME2a6FWpc-98Vg-1; Thu, 24 Feb 2022 07:38:06 -0500 X-MC-Unique: ULOiTRekME2a6FWpc-98Vg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8FC71835DE1; Thu, 24 Feb 2022 12:38:04 +0000 (UTC) Received: from fuller.cnet (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D5A5776BF9; Thu, 24 Feb 2022 12:38:03 +0000 (UTC) Received: by fuller.cnet (Postfix, from userid 1000) id 5A44F416D862; Thu, 24 Feb 2022 09:37:44 -0300 (-03) Date: Thu, 24 Feb 2022 09:37:44 -0300 From: Marcelo Tosatti To: Aaron Tomlin Cc: Frederic Weisbecker , Christoph Lameter , tglx@linutronix.de, mingo@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Phil Auld Subject: Re: [RFC PATCH] tick/sched: Ensure quiet_vmstat() is called when the idle tick was stopped too Message-ID: References: <20220203214339.1889971-1-atomlin@redhat.com> <20220217124729.GA743618@lothringen> <20220217142615.xqtiydixvnumyvei@ava.usersys.com> <20220217163205.GA748087@lothringen> <20220218125454.utlgmuhijklzr3if@ava.usersys.com> <20220219154616.pwsvh445x3vn7ltf@ava.usersys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Rspamd-Queue-Id: BDCA220004 X-Stat-Signature: ozo6fcrz6jn8d9jhaakmgnac58exrxib X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="S8om/3tA"; spf=none (imf31.hostedemail.com: domain of mtosatti@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam05 X-HE-Tag: 1645706289-824072 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, Feb 24, 2022 at 09:27:14AM -0300, Marcelo Tosatti wrote: > On Sat, Feb 19, 2022 at 03:46:16PM +0000, Aaron Tomlin wrote: > > On Fri 2022-02-18 12:54 +0000, Aaron Tomlin wrote: > > > On Thu 2022-02-17 17:32 +0100, Frederic Weisbecker wrote: > > > > > If I understand correctly, in the context of nohz_full, since such work is > > > > > deferred, it will only be handled in a scenario when the periodic/or > > > > > scheduling-clock tick is enabled i.e. the timer was reprogrammed on exit > > > > > from idle. > > > > > > > > Oh I see, it's a deferrable delayed work... > > > > Then I can see two other issues: > > > > > > > > 1) Can an interrupt in idle modify the vmstat and thus trigger the need to > > > > flush it? > > Yes. Page allocation and page freeing for example. > > 6 3730 ../mm/page_alloc.c <> > __mod_zone_freepage_state(zone, -(1 << order), > 4 1096 ../mm/page_alloc.c <<__free_one_page> > __mod_zone_freepage_state(zone, -(1 << order), > > > > > I believe it's the case and then the problem goes beyond nohz_full > > > > because if the idle interrupt fired while the tick is stopped and didn't set > > > > TIF_RESCHED, we go back to sleep without calling quiet_vmstat(). > > > > > > Yes: e.g. a nohz_full CPU, in idle code, could indeed receive a reschedule > > > IPI; re-enable local IRQs and generic idle code sees the TIF_NEED_RESCHED > > > flag against the idle task. Additionally, the selected task could > > > indirectly released a few pages [to satisfy a low-memory condition] and > > > modify CPU-specific vmstat data i.e. vm_stat_diff[NR_FREE_PAGES]. > > > > > > > > > > 2) What if we are running task A in kernel mode while the tick is stopped > > > > (nohz_full). Task A modifies the vmstat and goes to userspace for a long > > > > while. > > > > Your patch fixes case 1) but not case 2). The problem is that TIMER_DEFERRABLE > > > > should really be about dynticks-idle only and not dynticks-full. I've always > > > > been afraid about enforcing that rule though because that would break old > > > > noise-free setups. But perhaps I should... > > > > > > If I understand correctly, I agree. For the latter case, nothing can be > > > done unfortunately since the scheduling-clock tick is stopped. > > > > Hi Frederic, > > > > As far vmstat_updateas I understand, in the context of nohz_full, options are indeed > > limited; albeit, if we can ensure CPU-specific vmstat data is folded on > > return to idle [when required] then this should be good enough. > > I suppose the desired behaviour, with the deferred timer for vmstat_sync, is: > > "Allow the per-CPU vmstats to be out of sync, but for a maximum of > sysctl_stat_interval". > > But Aaron, vmstat_shepherd should be ensuring that per-CPU vmstat_update > work are queued, if the per-CPU vmstat are out of sync. > > And: > > static void > trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer) > { > if (!is_timers_nohz_active()) > return; > > /* > * TODO: This wants some optimizing similar to the code below, but we > * will do that when we switch from push to pull for deferrable timers. > */ > if (timer->flags & TIMER_DEFERRABLE) { > if (tick_nohz_full_cpu(base->cpu)) > wake_up_nohz_cpu(base->cpu); > return; > } > > * @TIMER_DEFERRABLE: A deferrable timer will work normally when the > * system is busy, but will not cause a CPU to come out of idle just > * to service it; instead, the timer will be serviced when the CPU > * eventually wakes up with a subsequent non-deferrable timer. > > You'd want that vmstat_update to execute regardless of whether there are > armed non-deferrable timers. > > Should fix both 1 and 2 AFAICS. Maybe just switching to a non-deferrable timer does not increase the frequency of vmstat_update calls so much ? It should happen once per second anyway. Then the "vmstats out of sync but for a maximum of sysctl_stat_interval" would be respected, rather than existance of non-deferrable timers.