Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4855862yba; Mon, 13 May 2019 00:30:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqymh4yQ/TL8cTrx1YxLVnd5dLc6WE5qAYionwYu3pxt3KS3ONrq0IeHXxFiqEm3ek5zsX3O X-Received: by 2002:a62:4e86:: with SMTP id c128mr30819395pfb.39.1557732606636; Mon, 13 May 2019 00:30:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557732606; cv=none; d=google.com; s=arc-20160816; b=Pb4HPGEV3krhS9G464D2ODd7VCHBPy2+fkf78lCqXKWDRwcgFOeCg2XliOVGOUrRFQ 33L7418IUsVzc0Xa/Z+Ts4OvcM5SwLKQaerdjWI7lj17qJC3ipIe19TZg2oZVnPy+jfp DV1gnGvbfcUSOy5yY51W7UPlxlY4dauYIMpvU5s9yfRCIozMKnlBIIszZYaqMAMxADj8 WnieUQVkSsyCvpGG4mGzji7d2EhYvhJXD7ij4120mSiHk+PNygttzsBXyGfvz2UgKop5 OcKpHrfieBNpV3vbY/+vLr8qO6G6a3xyxZX88v/DN8XOR/ahOKFo+XRgFjRNROaVhi5L +VvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SGbDi9g3ycl4SekWsQJ323qT4NTwYJN5RKmaJkwwOy8=; b=j+KmQhl3sqlJXmIZod/iznRIy8FM67xOfBb9MFCfgfHy79QxUW7AukQZtr/Sh3Uy8a fMzX2ZngW6Ixv+V2Ts2Sy7yVVNNE7v1VsVFXx+YmCKlKMbbtu5GdK/FoxM6ncMc3g2nY pWFVMz/W7HF4zIZWOxUxSGBgY6YkQxxkHUORoxfUkiLZHjwFzH3oYx/1W1SHveWkYECq FOEUAi5UqTuPSu9KCXYaH2MR72sKWNchcuzJGvVBISPgZu7v3d3ZrfB9qgQVwKSRQ5wS hBsC2I3LHK1EvVpfjoIkM+E8bL7twIh6ouQi9ZejqKY8UdrgQJ//+IPFlQeRyfrsbGYf R93Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jO7KprTN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si16365943pgk.279.2019.05.13.00.29.50; Mon, 13 May 2019 00:30:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jO7KprTN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727726AbfEMHCS (ORCPT + 99 others); Mon, 13 May 2019 03:02:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:54948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725980AbfEMHCR (ORCPT ); Mon, 13 May 2019 03:02:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E960E20B7C; Mon, 13 May 2019 07:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557730936; bh=bT3ak87mHPOn/6qzmCm3Jho7/L4DKAETYvoo3+eBUqY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jO7KprTNDJQMrxqqhWUNHHaFgScJGY1zYd9dCxmZPvnK+wiWF//WbPh18bDM/24nO G5LYSxV2L7+/5DpYnaMegQlQSmMQdZzDOlhIAFkFgGLlzPhelwohmSgOmZYBtlAJAI SRhqybZbIHjOEJecBGeqjLtEYL0NGJ7wxbbbdIRE= Date: Mon, 13 May 2019 09:02:14 +0200 From: Greg KH To: Daniel Wagner Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org Subject: Re: [PATCH v4.4.y] mm, vmstat: make quiet_vmstat lighter Message-ID: <20190513070214.GA26553@kroah.com> References: <20190513061237.4915-1-wagi@monom.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190513061237.4915-1-wagi@monom.org> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 13, 2019 at 08:12:37AM +0200, Daniel Wagner wrote: > From: Michal Hocko > > [ Upstream commit f01f17d3705bb6081c9e5728078f64067982be36 ] > > Mike has reported a considerable overhead of refresh_cpu_vm_stats from > the idle entry during pipe test: > > 12.89% [kernel] [k] refresh_cpu_vm_stats.isra.12 > 4.75% [kernel] [k] __schedule > 4.70% [kernel] [k] mutex_unlock > 3.14% [kernel] [k] __switch_to > > This is caused by commit 0eb77e988032 ("vmstat: make vmstat_updater > deferrable again and shut down on idle") which has placed quiet_vmstat > into cpu_idle_loop. The main reason here seems to be that the idle > entry has to get over all zones and perform atomic operations for each > vmstat entry even though there might be no per cpu diffs. This is a > pointless overhead for _each_ idle entry. > > Make sure that quiet_vmstat is as light as possible. > > First of all it doesn't make any sense to do any local sync if the > current cpu is already set in oncpu_stat_off because vmstat_update puts > itself there only if there is nothing to do. > > Then we can check need_update which should be a cheap way to check for > potential per-cpu diffs and only then do refresh_cpu_vm_stats. > > The original patch also did cancel_delayed_work which we are not doing > here. There are two reasons for that. Firstly cancel_delayed_work from > idle context will blow up on RT kernels (reported by Mike): > > CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.5.0-rt3 #7 > Hardware name: MEDION MS-7848/MS-7848, BIOS M7848W08.20C 09/23/2013 > Call Trace: > dump_stack+0x49/0x67 > ___might_sleep+0xf5/0x180 > rt_spin_lock+0x20/0x50 > try_to_grab_pending+0x69/0x240 > cancel_delayed_work+0x26/0xe0 > quiet_vmstat+0x75/0xa0 > cpu_idle_loop+0x38/0x3e0 > cpu_startup_entry+0x13/0x20 > start_secondary+0x114/0x140 > > And secondly, even on !RT kernels it might add some non trivial overhead > which is not necessary. Even if the vmstat worker wakes up and preempts > idle then it will be most likely a single shot noop because the stats > were already synced and so it would end up on the oncpu_stat_off anyway. > We just need to teach both vmstat_shepherd and vmstat_update to stop > scheduling the worker if there is nothing to do. > > [mgalbraith@suse.de: cancel pending work of the cpu_stat_off CPU] > Signed-off-by: Michal Hocko > Reported-by: Mike Galbraith > Acked-by: Christoph Lameter > Signed-off-by: Mike Galbraith > Signed-off-by: Andrew Morton > Signed-off-by: Linus Torvalds > Signed-off-by: Daniel Wagner > --- > Hi Greg, > > Upstream commmit 0eb77e988032 ("vmstat: make vmstat_updater deferrable > again and shut down on idle") was back ported in v4.4.178 > (bdf3c006b9a2). For -rt we definitely need the bugfix f01f17d3705b > ("mm, vmstat: make quiet_vmstat lighter") as well. > > Since the offending patch was back ported to v4.4 stable only, the > other stable branches don't need an update (offending patch and bug > fix are already in). > > Could you please queue the above patch for v4.4.y? Now queued up, thanks. greg k-h