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 9E2CBECAAA1 for ; Mon, 24 Oct 2022 11:54:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C8CB88E0002; Mon, 24 Oct 2022 07:54:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C3C898E0001; Mon, 24 Oct 2022 07:54:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B52438E0002; Mon, 24 Oct 2022 07:54:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A92BA8E0001 for ; Mon, 24 Oct 2022 07:54:31 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 765D980B73 for ; Mon, 24 Oct 2022 11:54:31 +0000 (UTC) X-FDA: 80055685542.14.31B1045 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 1D4384000F for ; Mon, 24 Oct 2022 11:54:30 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1D2E8612E3; Mon, 24 Oct 2022 11:54:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DBDBC433C1; Mon, 24 Oct 2022 11:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666612469; bh=/o+mi3lqLRFkJ7ON565vkXhmtzUNxmeBz98aaAWoL/o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SFgncGQwAjO9MyLrbGxP8Pz9fziukwMyBVefnpDoyTRqHqE4ETly6+FvTKZZZXs5j lwOxgMLfvEjZfa+j1jd+8KXTsXOO0s/kqU/LQvPorh0IqKn0YkrFZ6+v/xKIwBdhch NEXwbbBR4JZG+5Y1Q6xsesdqkbyvlGDL7HGTVYejKmFP1vB3inLU6U79LfFAlL5grr 8UFLCbzjzgXZJRillYBJzoZ3MlQJ3ktTIo6eDi68ev3lWlYVhb/vaZDybclLzl06Hu dam8tzXpjgshwgI7ecZzEomgH0H71zjcFUS10wL+bPabaNgXI6wVo8yZ5Fr59zcfNO 3pNKk+k4gWTBw== Date: Mon, 24 Oct 2022 13:54:26 +0200 From: Frederic Weisbecker To: Aaron Tomlin Cc: mtosatti@redhat.com, cl@linux.com, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, pauld@redhat.com, neelx@redhat.com, oleksandr@natalenko.name, atomlin@atomlin.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v8 3/5] mm/vmstat: Do not queue vmstat_update if tick is stopped Message-ID: <20221024115426.GA1287228@lothringen> References: <20220924152227.819815-1-atomlin@redhat.com> <20220924152227.819815-4-atomlin@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220924152227.819815-4-atomlin@redhat.com> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666612471; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0oCFss8FuFvFgx6838iX7pudCZ+rQZPWM5NmWpkzRlg=; b=SV8ngyQoaYngksifN8+jBZLJxUV2O1n+YkvoCF7i0jiaZDD0Qij6gUriqkG18dzsXpP7M/ m7gW4sqVrufkzjNF6aiW0F6nAa+oqLhanFKW6u6LKB6gfD7/um6JkR7JUCHx9JSLJYWC4F SNhSHQ32rGpldIWAH8cPbi8LI55ZXig= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SFgncGQw; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666612471; a=rsa-sha256; cv=none; b=mOUfc033+6g7fGvoOWcXrtJK1pxk81Evl2ub9Rq9EO9EA6nMVuKUoyvd6ba0jEo7VJhv5Z hn0LIbTNx6SXgrDOXXZZZNUZiJARABebTyMyHtAQx67imTWZH2xFW+htQMXV22Kn/15Xcb kY5n9JOEmOqHRiV92eLLtdJy8AEaUjU= X-Rspam-User: X-Rspamd-Queue-Id: 1D4384000F X-Stat-Signature: j6p4sitrcij6ms1rqsad38rfdc9e9c8j Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SFgncGQw; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org X-Rspamd-Server: rspam07 X-HE-Tag: 1666612470-842267 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 Sat, Sep 24, 2022 at 04:22:25PM +0100, Aaron Tomlin wrote: > From: Marcelo Tosatti > > From the vmstat shepherd, for CPUs that have the tick stopped, do not > queue local work to flush the per-CPU vmstats, since in that case the > flush is performed on return to userspace or when entering idle. Also > cancel any delayed work on the local CPU, when entering idle on nohz > full CPUs. Per-CPU pages can be freed remotely from housekeeping CPUs. > > Signed-off-by: Marcelo Tosatti > --- > mm/vmstat.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/mm/vmstat.c b/mm/vmstat.c > index 472175642bd9..3b9a497965b4 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -29,6 +29,7 @@ > #include > #include > #include > +#include > > #include "internal.h" > > @@ -1990,19 +1991,23 @@ static void vmstat_update(struct work_struct *w) > */ > void quiet_vmstat(void) > { > + struct delayed_work *dw; > + > if (system_state != SYSTEM_RUNNING) > return; > > if (!is_vmstat_dirty()) > return; > > + refresh_cpu_vm_stats(false); > + > /* > - * Just refresh counters and do not care about the pending delayed > - * vmstat_update. It doesn't fire that often to matter and canceling > - * it would be too expensive from this path. > - * vmstat_shepherd will take care about that for us. > + * If the tick is stopped, cancel any delayed work to avoid > + * interruptions to this CPU in the future. > */ > - refresh_cpu_vm_stats(false); > + dw = &per_cpu(vmstat_work, smp_processor_id()); > + if (delayed_work_pending(dw) && tick_nohz_tick_stopped()) > + cancel_delayed_work(dw); This is doing the costly cancel_delayed_work() which is only necessary right before entering entering in user. There are places where the tick is stopped but it's not necessary to cancel the work: * nohz_full enter idle * idle IRQs * nohz_full exit idle * nohz_full IRQ exit I suggest having quiet_vmstat_enter_user() which does: void quiet_vmstat_enter_user(void) { quiet_vmstat(); if (delayed_work_pending(dw) && tick_nohz_tick_stopped()) cancel_delayed_work(dw); } And call this one only before leaving the kernel. The rest can use quiet_vmstat(). Thanks.