Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp483949ybt; Mon, 6 Jul 2020 14:23:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmvikHypzy1q1y50SmyyKhK582Ke2LLRmXM6tdRAQmsExSzh/dwD/rDPk4IjrCxUjW+e+3 X-Received: by 2002:a17:906:1499:: with SMTP id x25mr44172225ejc.406.1594070622734; Mon, 06 Jul 2020 14:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594070622; cv=none; d=google.com; s=arc-20160816; b=pgt4Dsmedua0q7MWc3gFMjK9iQftItxvZR5fG+XvpCyoqMFL1JBrjsmyiRkD9ZRPa6 H8NSm3Y7oJB1j0nf9Uf736vcYRCCk+ApO3gfM03VmzJNf7R1yOahfKz2WdD8vtnmnHRB IIVURE4x9Bp0VLCu41SEYteINdnupbZ8IdsPCgukKNQ7/X90TiveqDGYwsoNe7yM52J1 N+v8nOTphw8zXjgtMCO5ps2pS6viz36qURzJrRPHZH3QThld8Pa5A6pjwauTWbPKmFmD 5cuACBWCmUTyd0GZbqN5szKzTltFNVfogaWAf00q8QEjeXumJ07nU5cMwWa9n5eJZ8Dg LjKQ== 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:mail-followup-to :message-id:subject:cc:to:from:date; bh=Q9nFpZEPuoVAIha2IbIxS90tanZFQV12K+SXQOUD/qs=; b=J9i1sUv0CCnIupPMKDo+uF8QXz7pFK4MeEgXEvx1X071EgOVnPFpo41iAh1552d658 UYMB0unDbLY8j9RwBdASGddJGK3Ys4QHk25p2a3GADX5z5FUa/XPcNeNbUPAouTIj2mL 0ay6YLXsH+oTmFJlwXtSFA/YiyDYVDJgIgXFHj1sSfjliPrKxNGri+EHE5oktVvz79KM aocTZyCtgzTCJPF9UklmIww8ZzMZbWX4Tve69GZvY4vjSJN2T1I88ro76vGBBpsPTzec bA9QNmzF3FiQD6b3j6iymy9XMuPEQbeffVachv3niYpa5cAVFZjwhUe/w5aDRDzGajF9 XAMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si13065019ejr.748.2020.07.06.14.23.20; Mon, 06 Jul 2020 14:23:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726572AbgGFVVG (ORCPT + 99 others); Mon, 6 Jul 2020 17:21:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgGFVVG (ORCPT ); Mon, 6 Jul 2020 17:21:06 -0400 Received: from scorn.kernelslacker.org (scorn.kernelslacker.org [IPv6:2600:3c03:e000:2fb::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCE3DC061755 for ; Mon, 6 Jul 2020 14:21:05 -0700 (PDT) Received: from [2601:196:4600:6634:ae9e:17ff:feb7:72ca] (helo=wopr.kernelslacker.org) by scorn.kernelslacker.org with esmtp (Exim 4.92) (envelope-from ) id 1jsYXp-0000fW-NF; Mon, 06 Jul 2020 17:20:57 -0400 Received: by wopr.kernelslacker.org (Postfix, from userid 1026) id 72F08560110; Mon, 6 Jul 2020 17:20:57 -0400 (EDT) Date: Mon, 6 Jul 2020 17:20:57 -0400 From: Dave Jones To: Peter Zijlstra Cc: Mel Gorman , Linux Kernel , mingo@kernel.org, Linus Torvalds , paul.gortmaker@windriver.com, valentin.schneider@arm.com Subject: Re: weird loadavg on idle machine post 5.7 Message-ID: <20200706212057.GA18637@codemonkey.org.uk> Mail-Followup-To: Dave Jones , Peter Zijlstra , Mel Gorman , Linux Kernel , mingo@kernel.org, Linus Torvalds , paul.gortmaker@windriver.com, valentin.schneider@arm.com References: <20200702171548.GA11813@codemonkey.org.uk> <20200702213627.GF3183@techsingularity.net> <20200703090226.GV4800@hirez.programming.kicks-ass.net> <20200703104033.GK117543@hirez.programming.kicks-ass.net> <20200703205153.GA19901@codemonkey.org.uk> <20200706145952.GB597537@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200706145952.GB597537@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Note: SpamAssassin invocation failed Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 06, 2020 at 04:59:52PM +0200, Peter Zijlstra wrote: > On Fri, Jul 03, 2020 at 04:51:53PM -0400, Dave Jones wrote: > > On Fri, Jul 03, 2020 at 12:40:33PM +0200, Peter Zijlstra wrote: > > > > looked promising the first few hours, but as soon as it hit four hours > > of uptime, loadavg spiked and is now pinned to at least 1.00 > > OK, lots of cursing later, I now have the below... > > The TL;DR is that while schedule() doesn't change p->state once it > starts, it does read it quite a bit, and ttwu() will actually change it > to TASK_WAKING. So if ttwu() changes it to WAKING before schedule() > reads it to do loadavg accounting, things go sideways. > > The below is extra complicated by the fact that I've had to scrounge up > a bunch of load-store ordering without actually adding barriers. It adds > yet another control dependency to ttwu(), so take that C standard :-) Man this stuff is subtle. I could've read this a hundred times and not even come close to approaching this. Basically me reading scheduler code: http://www.quickmeme.com/img/96/9642ed212bbced00885592b39880ec55218e922245e0637cf94db2e41857d558.jpg > I've booted it, and build a few kernels with it and checked loadavg > drops to 0 after each build, so from that pov all is well, but since > I'm not confident I can reproduce the issue, I can't tell this actually > fixes anything, except maybe phantoms of my imagination. Five hours in, looking good so far. I think you nailed it. Dave