Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6595404imu; Sun, 2 Dec 2018 22:39:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vy2AJU1sFXDYgDRfYdaAh68DIqloosjLmH9p8FbSShHV6I8d+dSNGOIwk2KUTlw5sPkQMT X-Received: by 2002:a17:902:6e4:: with SMTP id 91mr3691730plh.243.1543819169113; Sun, 02 Dec 2018 22:39:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543819169; cv=none; d=google.com; s=arc-20160816; b=twVBtx0iLYGSgxL9PHDNuv61gJTz3nFstHOMB1zDjSKZSz+Z07E0h9h0spccANJ5mz VI+Ea7XklEe1tjTtyaJ77a1iw97SNyR1o7ddLkJ8nDmW0WTs9b4sLw2wiwK4SP5dk0c3 TW8NeltJYq2VRp/4nU/YvNa8cklTBnvaeUt7iuA0imSq1g8VZY0eQzZ//DVE1C42nyRR O+TCRE87KMhI6A9dZmkrjZJvwXcJFZVUQWTHTKXdnX+FHESq9fOsT3huGKYQDeOu2HTd rpphGYqBrq6KgZY+YCe0PKkwpQZ8xSuTd6m4L46up5cdFG55IHfmd5ovqB16EsWuEo4m wtrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:organization:subject:cc:to:from:date :content-transfer-encoding:mime-version; bh=UMbFKpLKT3u4OVO6C5Xe2hVWsie7g+k2mp4/TS6QOyY=; b=G6RyC4CCHOOQkN02gy9jEvlNkUvamuPPNhTtOamdqJzJ0aGzetDF8Rqq0QbGwkcbMZ ydz985PpBK96RLdKsYwI5pA/V3yEtcY6RgIgv2FLrU6O3rkFK8HEJxwRbEkI+PDKVc+d E5UNs6ij1QZcwtTS8xjFAssVvCHu9M0ThZO7L/RAvHMI35ssek8DcMNiTNUehBKuauID dAPQ9X94Xhf8zys1Wwq9S8gWA3/60iNQPfsr9iNoBr4qFBCCywe2T0SSHgsn5fHPP8Nn lAVXJ492y72X6PCT3MFGrm0C0T1yJ5qeIMReEn5BPd9qiHNcYrcNM4vTqfVPOf9FPgVK eO7w== ARC-Authentication-Results: i=1; mx.google.com; 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 92si13415190pld.84.2018.12.02.22.39.14; Sun, 02 Dec 2018 22:39:29 -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; 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 S1725879AbeLCGin (ORCPT + 99 others); Mon, 3 Dec 2018 01:38:43 -0500 Received: from mx2.suse.de ([195.135.220.15]:40006 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725818AbeLCGin (ORCPT ); Mon, 3 Dec 2018 01:38:43 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 00E02AD02; Mon, 3 Dec 2018 06:38:38 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 02 Dec 2018 22:38:38 -0800 From: Davidlohr Bueso To: Prateek Sood Cc: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, sramana@codeaurora.org Subject: Re: [PATCH] percpu_rwsem: fix missed wakeup due to reordering of load Organization: SUSE Labs In-Reply-To: <1543590656-7157-1-git-send-email-prsood@codeaurora.org> References: <1543590656-7157-1-git-send-email-prsood@codeaurora.org> Message-ID: <734eb2ec2c3aeba1c4d054c1fceacef1@suse.de> X-Sender: dbueso@suse.de User-Agent: Roundcube Webmail Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-11-30 07:10, Prateek Sood wrote: > In a scenario where cpu_hotplug_lock percpu_rw_semaphore is already > acquired for read operation by P1 using percpu_down_read(). > > Now we have P1 in the path of releaseing the cpu_hotplug_lock and P2 > is in the process of acquiring cpu_hotplug_lock. > > P1 P2 > percpu_up_read() path percpu_down_write() path > > rcu_sync_enter() > //gp_state=GP_PASSED > > rcu_sync_is_idle() //returns false down_write(rw_sem) > > __percpu_up_read() > > [L] task = rcu_dereference(w->task) //NULL > > smp_rmb() [S] w->task = current > > smp_mb() > > [L] readers_active_check() > //fails > schedule() > > [S] __this_cpu_dec(read_count) > > Since load of task can result in NULL. This can lead to missed wakeup > in rcuwait_wake_up(). Above sequence violated the following constraint > in rcuwait_wake_up(): > > WAIT WAKE > [S] tsk = current [S] cond = true > MB (A) MB (B) > [L] cond [L] tsk > Hmm yeah we don't want rcu_wake_up() to get hoisted over the __this_cpu_dec(read_count). The smp_rmb() does not make sense to me here in the first place. Did you run into this scenario by code inspection or you actually it the issue? Thanks, Davidlohr