Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3525644pxb; Mon, 16 Nov 2020 17:50:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDspLjb09/QXq1SZO9coPAMzMrLWH8ZLpIIbluvyiBEe9gFqifw0Kalkvw5hT7oips/crQ X-Received: by 2002:a17:906:3a86:: with SMTP id y6mr17596323ejd.289.1605577853982; Mon, 16 Nov 2020 17:50:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605577853; cv=none; d=google.com; s=arc-20160816; b=B/8hY+oCNYMkTWUoSqL98Ro0PeqSmTICPbDIvGSGmMLinwAxyqh1jzboqPmAHz3IIi PTwEiW/nhMujUAO58pQiKfcvj6qt3rWDkQdcZmw0btW/8Dbcg+CKKp1ymzJGnMnTKTy4 I5c9WW85aTGEGU4snjyylbXcE8hIQk4aKxU+jy9bZ4EenzUv4vr1SNNVrU/mRnn7eGHA 8Q/+H1ZV7wOKbbkrd9aJe93r7119aEOA6ALokJer6uHzYq1s9/FVDWVcSIGn8/zu2i/E t2xYdH5alqouJsoJf5wAuJtWfvPg1M5u7FnWyCMBFcZ8HZoqoatZlGK96NLutToKzKeU HKXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kTUGIMj+xf9dxcnZPVWEpS4f+tMVOcGG3qYsy8JU/uo=; b=jk0AK/CiwZbEFIJVbd/tf/CUw7bHMmVj4TLLTnjXd+USOpTYBCzdDeehIMKRkvd6j1 8xUEkTpgLyMTNAFthzfW6al1hkZvALqqhLjh2JnGsGT/pVTAYX43AeWgCodBMuXQdslP dU7kf/ZcUbKLO0ispW/zK5r4LjqgP5HjYA6zTZmW8Bd/CwiubVaBRNkSx1PV6T/iLnLO BhCs/3zt0/Oklkor5ncKIP7C3K971XJYne4RGVH9XH2asB2bKCttQs0rdB99zXrrrY9K 2zLX+ud1yD1qHcvjTztS2EK3T4X4IEoPNboMfcYC+c5EnWWy2cYaVtfRkqr4Qo1GZI/X XQvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=scKbyAZa; 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 pg11si12591427ejb.92.2020.11.16.17.50.31; Mon, 16 Nov 2020 17:50:53 -0800 (PST) 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=pass header.i=@infradead.org header.s=casper.20170209 header.b=scKbyAZa; 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 S1727348AbgKPMyF (ORCPT + 99 others); Mon, 16 Nov 2020 07:54:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbgKPMyE (ORCPT ); Mon, 16 Nov 2020 07:54:04 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6866CC0613CF for ; Mon, 16 Nov 2020 04:54:04 -0800 (PST) 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:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kTUGIMj+xf9dxcnZPVWEpS4f+tMVOcGG3qYsy8JU/uo=; b=scKbyAZatnVBG2XU24NkUb3vRv PdGXJbxA9fBOEjb/AouKq5XeBuTBdsHJvoUbyQXLdTa+AMldNOmg5Tk2MDTZ2t8F0jlHVSP7q8R2+ S7BPnJYihCn2lzdYZ8pqeRsf3dsiKx3azWgV1fkfX1PnCyaguG3hDPaTXp5l60cNBAgYIFNR3I1CK DUNv85Au58d0tsH+9HWRHGPRYjsHdrpPmcUceMQWhVNb90dTkkTXpveSo/av1uyeFiLX4oQ+ryNRh 0ne4UAMa+5Z1CLGth5xvKJC5KNLXfIPzWBo9Y1tZzohKMdSzUvYtfyLXRHch7I8llvBgDrkeZJhR9 OcPF4O2w==; 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 1kee16-0004NK-C1; Mon, 16 Nov 2020 12:53:56 +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 64CE2301959; Mon, 16 Nov 2020 13:53:55 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 54FA22025CA2A; Mon, 16 Nov 2020 13:53:55 +0100 (CET) Date: Mon, 16 Nov 2020 13:53:55 +0100 From: Peter Zijlstra To: Mel Gorman Cc: Will Deacon , Davidlohr Bueso , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: Loadavg accounting error on arm64 Message-ID: <20201116125355.GB3121392@hirez.programming.kicks-ass.net> References: <20201116091054.GL3371@techsingularity.net> <20201116114938.GN3371@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201116114938.GN3371@techsingularity.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 16, 2020 at 11:49:38AM +0000, Mel Gorman wrote: > On Mon, Nov 16, 2020 at 09:10:54AM +0000, Mel Gorman wrote: > > I'll be looking again today to see can I find a mistake in the ordering for > > how sched_contributes_to_load is handled but again, the lack of knowledge > > on the arm64 memory model means I'm a bit stuck and a second set of eyes > > would be nice :( > > > > This morning, it's not particularly clear what orders the visibility of > sched_contributes_to_load exactly like other task fields in the schedule > vs try_to_wake_up paths. I thought the rq lock would have ordered them but > something is clearly off or loadavg would not be getting screwed. It could > be done with an rmb and wmb (testing and hasn't blown up so far) but that's > far too heavy. smp_load_acquire/smp_store_release might be sufficient > on it although less clear if the arm64 gives the necessary guarantees. > > (This is still at the chucking out ideas as I haven't context switched > back in all the memory barrier rules). IIRC it should be so ordered by ->on_cpu. We have: schedule() prev->sched_contributes_to_load = X; smp_store_release(prev->on_cpu, 0); on the one hand, and: sched_ttwu_pending() if (WARN_ON_ONCE(p->on_cpu)) smp_cond_load_acquire(&p->on_cpu) ttwu_do_activate() if (p->sched_contributes_to_load) ... on the other (for the remote case, which is the only 'interesting' one).