Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp128319ima; Fri, 1 Feb 2019 00:27:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IbuV5Y80F1wsKemPY9fA2aTB5+/rnoZXl/8UlyWrsEBt055d3x+ItHnU/Czk+0FC0OtV4RZ X-Received: by 2002:a63:2a83:: with SMTP id q125mr2297605pgq.98.1549009654405; Fri, 01 Feb 2019 00:27:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549009654; cv=none; d=google.com; s=arc-20160816; b=uK9l0HjVuKT/e/XzqtDH/2aXdzCvY/DELEIFe1UOQzvbAisjIugtjYdtAnPPxAYrWZ cppHcrMbeogfXmAsGgz66KmnH5e6+b0J7PSXNt4kVbtjHN63KnZZXyJTdXNNkocZewRk NYII2eTvqE+TZol3Ybt292DvevyRs4dtfnr01ogRL6jeN2A/wGpsQCGu4QXV54TMWAq9 XRxHv0X5mGbuq6rE3aLhKq2awlgfk5W1vh9fNp9N+qaHeEctIihK9/SrYHb5u+fZ7obM ThHDs8vN6VOdzqtYKS6UgGfQXLYKDwY7jWMeMRcp1H2g1zYS1xBnhli8o0YKr6U/zsfA pocw== 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=bD/HAUVU3CJpn1uqh5ZgcGs2AWd8b4ab6ML6LMiPHmQ=; b=MTP9kwWzJXEUuxwtxsAolfw05ijBuAzmioHSAoOdp7ZJCKAQQsykKm5S68vqUKU/Xk xTFTvR5Ymo3gwi3cDYKuSCCT0kKVyDPz59T6mROgJrFDI7S/UNoYmZh8l1aHwKU+JAAk /By0oZBS/EZt1SB9UkOAEdS9rSrG4ZuQ3Gg6/pVObmUS90/VNp5464G6+IOUvQNI2gHv 524FwzoAZqZ4hzqaPaPa1dudA/xRWCVE1I49sbXSSxIsfNitUcTTX75D36HgAB3dxmLR goAMj4wj5MFjgA7WWU3JuHcM89iPZ2FZABy+w5HxFmoley4gAQK2OCMGtao+lFAn8Ytu kkSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=wU4kfxQ9; 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 h6si8046209plk.231.2019.02.01.00.27.18; Fri, 01 Feb 2019 00:27:34 -0800 (PST) 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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=wU4kfxQ9; 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 S1727935AbfBAI1A (ORCPT + 99 others); Fri, 1 Feb 2019 03:27:00 -0500 Received: from merlin.infradead.org ([205.233.59.134]:42438 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbfBAI1A (ORCPT ); Fri, 1 Feb 2019 03:27:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bD/HAUVU3CJpn1uqh5ZgcGs2AWd8b4ab6ML6LMiPHmQ=; b=wU4kfxQ9BTUlhPVwgaGoazLS7 QztAI8bAx8RNVk0Cp5wCtWNPCifMda4QuAuWYnJufW4dVCphxEUrcrrb3TPAYoHHG2XzC9o6xbvCu FP1BbXdZq60Dc7tAsEEqpiqILUJjqWI69WMiLHBgKTvzqm/PnS09756d2w5gRyzFlIvW4zHOFGMd2 TZg3SpV3To5XixSyfhAdm2uPaMab7v/ypn+OTAacjiuiQeIfJYe4Dvx+L8Fkg/vw8hLD+Q5rVGE6W lm9MTVZRaoWKV77vxsFKHkAqWa4LV81Pz6ng0dAbdtuPjpvCXYbLiT6fTCeXjDPjAosfNDpRbUMUp NID9PsMQA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpU9y-0005uB-Jt; Fri, 01 Feb 2019 08:26:50 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0C62228480B5C; Fri, 1 Feb 2019 09:26:48 +0100 (CET) Date: Fri, 1 Feb 2019 09:26:48 +0100 From: Peter Zijlstra To: Andrea Parri Cc: linux-kernel@vger.kernel.org, Ingo Molnar , "Paul E. McKenney" , Alan Stern , Will Deacon Subject: Re: [PATCH v2] sched: Use READ_ONCE()/WRITE_ONCE() in move_queued_task()/task_rq_lock() Message-ID: <20190201082647.GA31498@hirez.programming.kicks-ass.net> References: <20190121155240.27173-1-andrea.parri@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190121155240.27173-1-andrea.parri@amarulasolutions.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 21, 2019 at 04:52:40PM +0100, Andrea Parri wrote: > move_queued_task() synchronizes with task_rq_lock() as follows: > > move_queued_task() task_rq_lock() > > [S] ->on_rq = MIGRATING [L] rq = task_rq() > WMB (__set_task_cpu()) ACQUIRE (rq->lock); > [S] ->cpu = new_cpu [L] ->on_rq > > where "[L] rq = task_rq()" is ordered before "ACQUIRE (rq->lock)" by an > address dependency and, in turn, "ACQUIRE (rq->lock)" is ordered before > "[L] ->on_rq" by the ACQUIRE itself. > > Use READ_ONCE() to load ->cpu in task_rq() (c.f., task_cpu()) to honor > this address dependency. Also, mark the accesses to ->cpu and ->on_rq > with READ_ONCE()/WRITE_ONCE() to comply with the LKMM. > > Signed-off-by: Andrea Parri Thanks!