From patchwork Thu Jan 29 08:38:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 43899 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6E1D624119 for ; Thu, 29 Jan 2015 08:38:46 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id l4sf16884249lbv.1 for ; Thu, 29 Jan 2015 00:38:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=Lu7Px91pgbr4Xux5TEyDGsl+S8bL5zVHl33zcvplBn8=; b=dbeI++joc21yBFw9C9849qG2AxjwFkPvjtwiVDCtRN6GlhwyxvL4zII1WzFkqJKcpt OqorYu7kumqUsNkT3n2Fv93sQIRQcNkpAnKdb/kfGSq2fQv+vXEqp622dIV8/6EAodtN aMz93vhJml8/smIYTy9Qx8VNm81qDYQJ3wXrtW/F1elG1vHvxuapOwftQEWVbJPUQvoP hk0ErzvjTYHSf2OsBXvpGGfrjRzHkkuW3fZ3lPXDiZLZnibckkApZ4BgU7HD+oTadlAG w0gDtt6hTu3wVEvZqH1Zh7ZnWNpNVXQkPGO+cdf09lssCu/370roawGPa+xptxyCEhoF qYjA== X-Gm-Message-State: ALoCoQnZzNAk1eJo/k18jQnTGFgBbtwAEEse2gy0PIcHO6b9Bpey9WNHkPa6m7lVoANG5gcqL86J X-Received: by 10.113.5.170 with SMTP id cn10mr1538701lbd.21.1422520725335; Thu, 29 Jan 2015 00:38:45 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.35 with SMTP id lt3ls265253lac.45.gmail; Thu, 29 Jan 2015 00:38:45 -0800 (PST) X-Received: by 10.152.4.8 with SMTP id g8mr7132544lag.58.1422520725199; Thu, 29 Jan 2015 00:38:45 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id dd11si6668477lac.130.2015.01.29.00.38.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 00:38:44 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id b6so25478596lbj.11 for ; Thu, 29 Jan 2015 00:38:44 -0800 (PST) X-Received: by 10.112.125.41 with SMTP id mn9mr12841701lbb.80.1422520724774; Thu, 29 Jan 2015 00:38:44 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1690812lbj; Thu, 29 Jan 2015 00:38:43 -0800 (PST) X-Received: by 10.66.172.36 with SMTP id az4mr12385174pac.77.1422520722880; Thu, 29 Jan 2015 00:38:42 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si8863505pdi.249.2015.01.29.00.38.42; Thu, 29 Jan 2015 00:38:42 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752259AbbA2Iik (ORCPT + 11 others); Thu, 29 Jan 2015 03:38:40 -0500 Received: from mail-oi0-f51.google.com ([209.85.218.51]:64195 "EHLO mail-oi0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751018AbbA2Iij (ORCPT ); Thu, 29 Jan 2015 03:38:39 -0500 Received: by mail-oi0-f51.google.com with SMTP id x69so24500140oia.10 for ; Thu, 29 Jan 2015 00:38:39 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.114.40 with SMTP id jd8mr4927007oeb.12.1422520718954; Thu, 29 Jan 2015 00:38:38 -0800 (PST) Received: by 10.182.33.34 with HTTP; Thu, 29 Jan 2015 00:38:38 -0800 (PST) In-Reply-To: <1422513761-8230-1-git-send-email-ethan.zhao@oracle.com> References: <1422513761-8230-1-git-send-email-ethan.zhao@oracle.com> Date: Thu, 29 Jan 2015 14:08:38 +0530 Message-ID: Subject: Re: [PATCH] cpufreq: fix another race between PPC notification and vcpu_hotplug() From: Viresh Kumar To: Ethan Zhao , santosh shilimkar Cc: "Rafael J. Wysocki" , "linux-pm@vger.kernel.org" , Linux Kernel Mailing List , Ethan Zhao Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Looks like you just save my time here, Santosh has also reported a similar race in a personal mail.. On 29 January 2015 at 12:12, Ethan Zhao wrote: > There is race observed between PPC changed notification handler worker thread > and vcpu_hotplug() called within xenbus_thread() context. > It is shown as following WARNING: > > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 4 at include/linux/kref.h:47 > kobject_get+0x41/0x50() > Modules linked in: acpi_cpufreq(+) nfsd auth_rpcgss nfs_acl > lockd grace sunrpc xfs libcrc32c sd_mod ixgbe igb mdio ahci hwmon > ... > [ 14.003548] CPU: 0 PID: 4 Comm: kworker/0:0 Not tainted > ... > [ 14.003553] Workqueue: kacpi_notify acpi_os_execute_deferred > [ 14.003554] 0000000000000000 000000008c76682c ffff88094c793af8 > ffffffff81661b14 > [ 14.003556] 0000000000000000 0000000000000000 ffff88094c793b38 > ffffffff81072b61 > [ 14.003558] ffff88094c793bd8 ffff8812491f8800 0000000000000292 > 0000000000000000 > [ 14.003560] Call Trace: > [ 14.003567] [] dump_stack+0x46/0x58 > [ 14.003571] [] warn_slowpath_common+0x81/0xa0 > [ 14.003572] [] warn_slowpath_null+0x1a/0x20 > [ 14.003574] [] kobject_get+0x41/0x50 > [ 14.003579] [] cpufreq_cpu_get+0x75/0xc0 > [ 14.003581] [] cpufreq_update_policy+0x2e/0x1f0 > [ 14.003586] [] ? up+0x32/0x50 > [ 14.003589] [] ? acpi_ns_get_node+0xcb/0xf2 > [ 14.003591] [] ? acpi_evaluate_object+0x22c/0x252 > [ 14.003593] [] ? acpi_get_handle+0x95/0xc0 > [ 14.003596] [] ? acpi_has_method+0x25/0x40 > [ 14.003601] [] acpi_processor_ppc_has_changed+0x77/0x82 > [ 14.003604] [] ? move_linked_works+0x66/0x90 > [ 14.003606] [] acpi_processor_notify+0x58/0xe7 > [ 14.003609] [] acpi_ev_notify_dispatch+0x44/0x5c > [ 14.003611] [] acpi_os_execute_deferred+0x15/0x22 > [ 14.003614] [] process_one_work+0x160/0x410 > [ 14.003616] [] worker_thread+0x11b/0x520 > [ 14.003617] [] ? rescuer_thread+0x380/0x380 > [ 14.003621] [] kthread+0xe1/0x100 > [ 14.003623] [] ? kthread_create_on_node+0x1b0/0x1b0 > [ 14.003628] [] ret_from_fork+0x7c/0xb0 > [ 14.003630] [] ? kthread_create_on_node+0x1b0/0x1b0 > [ 14.003631] ---[ end trace 89e66eb9795efdf7 ]--- > > Thread A: Workqueue: kacpi_notify > > acpi_processor_notify() > acpi_processor_ppc_has_changed() > cpufreq_update_policy() > cpufreq_cpu_get() > kobject_get() > > Thread B: xenbus_thread() > > xenbus_thread() > msg->u.watch.handle->callback() > handle_vcpu_hotplug_event() > vcpu_hotplug() > cpu_down() > __cpu_notify(CPU_DOWN_PREPARE..) > cpufreq_cpu_callback() > __cpufreq_remove_dev_prepare() > update_policy_cpu() > kobject_move() Where is the race ? How do you say this is racy ? I am not sure if the problem is with kobject_move(), to me it looked like the problem is with cpufreq_policy_put_kobj() and we tried to do kobject_get() after the kobject has been freed.. I don't agree to the solution you gave, but lets first make sure what the problem is, and then take any action against it. Please try this patch and let us know if it fixes it for you: the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 4473eba1d6b0..5ced9cca4822 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1411,6 +1411,7 @@ static int __cpufreq_remove_dev_finish(struct device *dev, read_lock_irqsave(&cpufreq_driver_lock, flags); policy = per_cpu(cpufreq_cpu_data, cpu); + per_cpu(cpufreq_cpu_data, cpu) = NULL; read_unlock_irqrestore(&cpufreq_driver_lock, flags); if (!policy) { @@ -1466,7 +1467,6 @@ static int __cpufreq_remove_dev_finish(struct device *dev, } } - per_cpu(cpufreq_cpu_data, cpu) = NULL; return 0; } -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in