Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4920235ima; Tue, 5 Feb 2019 03:35:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IbTJI3CF3zNj9THFqRs75+Yzz1u3gCmBGwSztkxQL5WSVIEkgPPKkKdgkBngiFNDpmTo5IZ X-Received: by 2002:a17:902:d83:: with SMTP id 3mr4588776plv.43.1549366525689; Tue, 05 Feb 2019 03:35:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549366525; cv=none; d=google.com; s=arc-20160816; b=e5p4j119b8t5XAc/7lnlGASmstMnndu4AJZl75Xr+FhtIxJlZuRjYooO3cTVm313lE y9FsmnED/CRNkuvxEO4jYXefnVxiMUadyxSh9cywJhGyeJrjKXSqnF0MDwCdR8hS3HOp /MfYO5GCjgN3g45d6j06gMj1L+8DlFyqBesHXmG0nYOqTcB8oYjSSSK3YYeG+QcfcTJ2 3byu6oK+FgXnbdrE45/DeTMuzX0SjjwxJ0aVRWdR2pdfUv/08Evp6Ru3ZYFtXInTIPqA DqgBgb02NuABQKFmcIMwg9IqvX5SzPv7evGi/9ckGg+yL30v9MddxbbgJTZMANSiTHIU 2m/Q== 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:from:references:cc:to:subject; bh=tbJ1CcRDeS6EUq/yUnyPv60+Jo9J/KtP5d2wqzt5sjo=; b=FjAuz2YNGDGpyCRpfU1KXWEMoV0HHZuelKRiMt/8YVM/V79sGXC++PZhyhEje0Z9dH xE8DvpdpQSR8jz+m/AFMgXZSmBPvgfcpTrH3AAZNtoLpKZrgi4iE25MDTQ2QrO4nFzlb FxQjR3C1B1WybM34eDyTlBy4V427ruxrXvmvmjUvxuu1DnzheOGcJwIVjL9z/Ubu0E4Q X1c33OSTIE5haL41VPsi/+WNhS7gIssBN7NTqW5bm1cPG2CCvqK6z69U2HGtIT2W6+or SgpdbMvh08BXt3T0yTA73viD/PT7rSkYrSL4abFNY/qJ6IjhDTDg0xyZO3oLTxBsN/bE c8bA== 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 v6si918555pgs.206.2019.02.05.03.35.07; Tue, 05 Feb 2019 03:35:25 -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 S1728088AbfBELUC (ORCPT + 99 others); Tue, 5 Feb 2019 06:20:02 -0500 Received: from foss.arm.com ([217.140.101.70]:39896 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727949AbfBELUC (ORCPT ); Tue, 5 Feb 2019 06:20:02 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8B2E480D; Tue, 5 Feb 2019 03:20:01 -0800 (PST) Received: from [10.1.196.93] (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A05A73F675; Tue, 5 Feb 2019 03:19:59 -0800 (PST) Subject: Re: [PATCH 1/5] perf/arm-cci: Fix CPU hotplug race avoidance To: robin.murphy@arm.com, will.deacon@arm.com, mark.rutland@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, peterz@infradead.org, tglx@linutronix.de, bigeasy@linutronix.de, Meng.Li@windriver.com References: <606ff8c3f7f35ccdcb4b52a49f692fb20e27359c.1549299188.git.robin.murphy@arm.com> From: Suzuki K Poulose Message-ID: <3ebabec2-5423-9aca-19aa-7cd96353efd6@arm.com> Date: Tue, 5 Feb 2019 11:19:55 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <606ff8c3f7f35ccdcb4b52a49f692fb20e27359c.1549299188.git.robin.murphy@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Robin, On 04/02/2019 17:09, Robin Murphy wrote: > The arm-cci probe logic faces a cyclic dependency wherein it has to pick > a valid CPU to associate with before registering the PMU device, has to > have the PMU state initialised before handling hotplug events in case it > must be migrated, but has to have the hotplug notifier registered before > the chosen CPU may go offline lest things get out of sync. The present > code has tried to solve the races by using get_cpu() to pick the current > CPU and prevent it from disappearing while the other two registrations > are performed, but that results in taking mutexes with preemption > disabled, which makes certain configurations very unhappy: > > [ 1.983337] BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:2004 > [ 1.983340] in_atomic(): 1, irqs_disabled(): 0, pid: 1, name: swapper/0 > [ 1.983342] Preemption disabled at: > [ 1.983353] [] cci_pmu_probe+0x1dc/0x488 > [ 1.983360] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.18.20-rt8-yocto-preempt-rt #1 > [ 1.983362] Hardware name: ZynqMP ZCU102 Rev1.0 (DT) > [ 1.983364] Call trace: > [ 1.983369] dump_backtrace+0x0/0x158 > [ 1.983372] show_stack+0x24/0x30 > [ 1.983378] dump_stack+0x80/0xa4 > [ 1.983383] ___might_sleep+0x138/0x160 > [ 1.983386] __might_sleep+0x58/0x90 > [ 1.983391] __rt_mutex_lock_state+0x30/0xc0 > [ 1.983395] _mutex_lock+0x24/0x30 > [ 1.983400] perf_pmu_register+0x2c/0x388 > [ 1.983404] cci_pmu_probe+0x2bc/0x488 > [ 1.983409] platform_drv_probe+0x58/0xa8 > > However, we don't actually mind being preempted or migrated at this > point; all that really matters is that whichever CPU we pick does not > get offlined before we're done. Thus, do the robust thing and instead > take the lock to inhibit CPU hotplug for the duration. This also > revealed an additional race in assigning the global pointer too late > relative to the hotplug notifier, so that gets fixed in the process. > > Reported-by: "Li, Meng" > Signed-off-by: Robin Murphy Thanks for fixing the issues. Reviewed-by: Suzuki K Poulose