Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp822444ybt; Tue, 7 Jul 2020 00:50:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxB+Cokf9FaaAhNZY3bVBUifuVC31mYSdYrhv6EENkxgJ9t8fk1pwAB9H7SBZ+u3uWFF2fO X-Received: by 2002:a05:6402:31ad:: with SMTP id dj13mr17132248edb.88.1594108209869; Tue, 07 Jul 2020 00:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594108209; cv=none; d=google.com; s=arc-20160816; b=xiJ8liXT3k5+OUWDBglksoOj2pkRy/0yAl8yoCSR1bCXqsqMAzEl1GV8PgSir7gGse fmTXS/zcDh8gVpOXFD4cYOaMkHhqtjN0s/UwLV7JNioaQ2wdDIibR4z1yYQcIVS+vJrb RFatO6TNeg6pgDI7aIZ0One730ycopKojwJNbW9h8O3C7QXh2Rk/FCjxZyeQoTnd3zR3 sLe7PA/bwOaiqTa0SVQOhdH2QC1TDWBg/LWMJSJhL2XJ/AHbmPGbobcuglI1YkVgEnMB pVYxD2WV6z85se1C6y2IKNVT3sYWhonhOqJkkDCXSOsAzsmxEE/T4yCT2v5Ng257oXmX tFvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=qpCyLxWI8+vr0RRTomM8CK40nhOuK0K2F+B2/Nf6Os8=; b=fBlzjNDIdDnHYpqIYxImvclgnTkn9T2nJUAPi4i2Up32vKnLrdOMpS9X3ctL7lbmd8 dGUWIPvs1Xs8R7IlROOF4/g2/osOOF7DqvqvLxXtz5GSNn5X4vcatEtwP3839xSyyziE EkHwc+fmM+zArX3Mh2SCp5oGfrW3tA79I8qbJwqzm4EtC5DGikriHDRNPL42gYdSkM+5 rNWBwiNkM7PsUgEwMMr/6CpZbQ3THf3tuypmCNivuUoTb3ZAzkC1GI5ObgqU/k+Bnpfj EbGo7+qJijfgIslKBl646F/a4+uhRQ6qc5/3/gvE6JaW8hg9UVP60aJ98lVHAq0/VCqd 2p4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b="YbqqsTv/"; 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 f13si14406666eje.212.2020.07.07.00.49.46; Tue, 07 Jul 2020 00:50:09 -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; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b="YbqqsTv/"; 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 S1728224AbgGGHtM (ORCPT + 99 others); Tue, 7 Jul 2020 03:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725944AbgGGHtL (ORCPT ); Tue, 7 Jul 2020 03:49:11 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64C01C061755 for ; Tue, 7 Jul 2020 00:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=qpCyLxWI8+vr0RRTomM8CK40nhOuK0K2F+B2/Nf6Os8=; b=YbqqsTv/GfrsMC95U9tokQPr5n +etquVO7AkoJT+OeTAPPUl+hN9Caw6UCaPupuzoGRC1liysB6zpQj8EhGX3pcL9r7A26li+subYry FW/4FqoLVT+QwzMUV6cELMtyvoRnS8NWcAMqoJ22csTiSpPAxuR+CuImX7tHe0FxIK+1zhsKyBqG+ LvjvrJ4SIYNdi38lNE1WgF0fvlIz/DBhp5eBoY7cQAqptFtHiMIz96cOi0JI0mRfVQCFez/L86dxD QrN8rPUAqndcJka26PzVfe4/R+Oe66a0ECSnXGpw6q9fScNRwtUFxLYurP9KGzA5eEp31QidcKbqE PokuypKw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsiLa-0001Kv-LH; Tue, 07 Jul 2020 07:48:59 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8B3823006D0; Tue, 7 Jul 2020 09:48:57 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 71026213C65B5; Tue, 7 Jul 2020 09:48:57 +0200 (CEST) Date: Tue, 7 Jul 2020 09:48:57 +0200 From: Peter Zijlstra To: Dave Jones , 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: <20200707074857.GJ4800@hirez.programming.kicks-ass.net> 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> <20200706212057.GA18637@codemonkey.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200706212057.GA18637@codemonkey.org.uk> 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 05:20:57PM -0400, Dave Jones wrote: > 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 Heh, that one made me nearly spill my tea, much funnies :-) But yes, Dave Chinner also complained about this for the previous fix. I've written this: https://lore.kernel.org/lkml/20200703133259.GE4781@hirez.programming.kicks-ass.net/ to help with that. But clearly I'll need to update that patch again after this little adventure. > > 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. \o/ hooray! Thanks for testing Dave!