Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1910807imu; Wed, 12 Dec 2018 06:29:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vx+2YgjuAdKeVAW1RAQGuTSCrt0CiSwrxbVnVt+PbDk0s2Lce0Jlh5BuDNRcEj0DAGPgcr X-Received: by 2002:a17:902:70c6:: with SMTP id l6mr20550597plt.30.1544624941894; Wed, 12 Dec 2018 06:29:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544624941; cv=none; d=google.com; s=arc-20160816; b=YXsNbXiRRAhL541GiQOoOE/+/00KDtx+vSgmW49wAj4t50of3kNqsKR0fp9v1WaPot 6mrq0Vl+TaDEj1zDA8t9XR68rPf5uFVQgM4aBUMLtJPgT16SwFPt4oORAixStIyNIe+c zjkxLr58R/1YBx3VgCZgunNoym8hE5jYM6rF3oDUcR8UHaEGzH3uYAsPTSEb6gCQOA2K L6fJ3aXUgkJKBhvirgOfVFkFV2EHUqejjEU2j+mxqShymvHipKQzbhFTFEMx57wToDLl 6M2jw4EdXV4UpIkVdU2wi6xOKPVIcRZ4PGdNBmr1efOZQ5329Efr0rPBEPkv663w7vPX 1UeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dmarc-filter :dkim-signature:dkim-signature; bh=qANfUN/XRJDVuT3evzcyPcxWfSSgLokpx7NT7u/Zhoc=; b=Yk64A2KKV/QjmZaz30eGKkkXKmU3F7WSq6Dabva2AR/zEsmNnk78q/mz2oZTTbm112 WDmmIKS5nEvIcW8Un7uurSQcf2oiu5G9lS5Ks1xZnWEo2bYLU9sQn32GakhGMC3+54sY 69qCisGMjM52jV4gJ7rE/9+XEeGumg9bZ1IgXUt6AizaLaZlu8FrAwCy0+iXWnHxEFgD 13dlef8uIUpxtvAvj7V+cbbUYTF4eIc2wP+XTaM34D32AvHM0YBg+86cL8Q6bYcip+oj /b7YLpogCgXFn03t4YmGztlWwXenPtF/MqOzXJP7wPDta0gXG+Ut91jhg2kCMvcP/URG 6PoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=c93XMtq5; dkim=pass header.i=@codeaurora.org header.s=default header.b=c93XMtq5; 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 c132si14202923pga.597.2018.12.12.06.28.47; Wed, 12 Dec 2018 06:29:01 -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=pass header.i=@codeaurora.org header.s=default header.b=c93XMtq5; dkim=pass header.i=@codeaurora.org header.s=default header.b=c93XMtq5; 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 S1727733AbeLLO0S (ORCPT + 99 others); Wed, 12 Dec 2018 09:26:18 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:51358 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727522AbeLLO0R (ORCPT ); Wed, 12 Dec 2018 09:26:17 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E77D7602FD; Wed, 12 Dec 2018 14:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1544624776; bh=uDDmpUf2YbfqjVwDrb9eizDsvwe4lGGPwMcnt+3kBE8=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=c93XMtq5cL/OB7UTdQZfglxmOQX+bCbgs0h7ieqNd/wyRZ+qlEe0wlIOJvUgdQFex 4M/Hdqrtv3XIyKecRJo3jZIUGHGibAs47vEig7dbrK2A6fuzUmgb4MSSeM/YQeE29V mXxYBiw/CKs5ZSAYMqRqpTNaa1d+D9kgAx0okAYk= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from [10.204.79.19] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: prsood@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B14AC601EA; Wed, 12 Dec 2018 14:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1544624776; bh=uDDmpUf2YbfqjVwDrb9eizDsvwe4lGGPwMcnt+3kBE8=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=c93XMtq5cL/OB7UTdQZfglxmOQX+bCbgs0h7ieqNd/wyRZ+qlEe0wlIOJvUgdQFex 4M/Hdqrtv3XIyKecRJo3jZIUGHGibAs47vEig7dbrK2A6fuzUmgb4MSSeM/YQeE29V mXxYBiw/CKs5ZSAYMqRqpTNaa1d+D9kgAx0okAYk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B14AC601EA Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=prsood@codeaurora.org Subject: Re: [PATCH] percpu_rwsem: fix missed wakeup due to reordering of load From: Prateek Sood To: Davidlohr Bueso Cc: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, sramana@codeaurora.org References: <1543590656-7157-1-git-send-email-prsood@codeaurora.org> <734eb2ec2c3aeba1c4d054c1fceacef1@suse.de> <7803e498-5fc8-9b72-3e1b-76005f7673a3@codeaurora.org> Message-ID: Date: Wed, 12 Dec 2018 19:56:07 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <7803e498-5fc8-9b72-3e1b-76005f7673a3@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/04/2018 01:06 AM, Prateek Sood wrote: > On 12/03/2018 12:08 PM, Davidlohr Bueso wrote: >> 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 > > I have checked one issue where it seems that cpu hotplug code > path is not able to get cpu_hotplug_lock in write mode and there > is a reader pending for cpu hotplug path to release > percpu_rw_semaphore->rwsem to acquire cpu_hotplug_lock. > This caused a deadlock. > > From code inspection also it seems to be not adhering to arm64 > smp_rmb() constraint of load/load-store ordering guarantee. > > > Thanks, > Prateek > Folks, Please confirm if the suspicion of smp_rmb is correct. IMO, it should be smp_mb() translating to dmb ish. Thanks Prateek -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project