From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755564AbaHARSg (ORCPT ); Fri, 1 Aug 2014 13:18:36 -0400 Received: from smtp.codeaurora.org ([198.145.11.231]:56680 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751460AbaHARSe (ORCPT ); Fri, 1 Aug 2014 13:18:34 -0400 Message-ID: <53DBCBE8.6010809@codeaurora.org> Date: Fri, 01 Aug 2014 10:18:32 -0700 From: Stephen Boyd User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Prarit Bhargava CC: Saravana Kannan , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Viresh Kumar , Lenny Szubowicz , linux-pm@vger.kernel.org Subject: Re: [PATCH] cpufreq, store_scaling_governor requires policy->rwsem to be held for duration of changing governors [v2] References: <1406634362-811-1-git-send-email-prarit@redhat.com> <2066166.pXm4lKLOID@vostro.rjw.lan> <53DA8389.80804@redhat.com> <1917362.abr2Y4p7vh@vostro.rjw.lan> <53DA8A41.2030601@redhat.com> <53DAA60B.6040802@codeaurora.org> <53DAA749.5080506@redhat.com> <53DAA95B.2040505@codeaurora.org> <53DAB038.3050007@redhat.com> <53DABFA6.6090503@codeaurora.org> <53DACA26.1000908@redhat.com> <53DAE592.2030909@codeaurora.org> <53DB6B81.6050400@redhat.com> In-Reply-To: <53DB6B81.6050400@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/01/14 03:27, Prarit Bhargava wrote: > > Can you send me the test and the trace of the deadlock? I'm not creating it with: > This was with conservative as the default, and switching to ondemand # cd /sys/devices/system/cpu/cpu2/cpufreq # ls affected_cpus scaling_available_governors conservative scaling_cur_freq cpuinfo_cur_freq scaling_driver cpuinfo_max_freq scaling_governor cpuinfo_min_freq scaling_max_freq cpuinfo_transition_latency scaling_min_freq related_cpus scaling_setspeed scaling_available_frequencies stats # cat conservative/down_threshold 20 # echo ondemand > scaling_governor ====================================================== [ INFO: possible circular locking dependency detected ] 3.16.0-rc3-00039-ge1e38f124d87 #47 Not tainted ------------------------------------------------------- sh/75 is trying to acquire lock: (s_active#9){++++..}, at: [] kernfs_remove_by_name_ns+0x3c/0x84 but task is already holding lock: (&policy->rwsem){+++++.}, at: [] store+0x68/0xb8 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&policy->rwsem){+++++.}: [] kernfs_fop_open+0x138/0x298 [] do_dentry_open.isra.12+0x1b0/0x2f0 [] finish_open+0x20/0x38 [] do_last.isra.37+0x5ac/0xb68 [] path_openat+0xb4/0x5d8 [] do_filp_open+0x2c/0x80 [] do_sys_open+0x10c/0x1c8 [] ret_fast_syscall+0x0/0x48 -> #0 (s_active#9){++++..}: [] __kernfs_remove+0x250/0x300 [] kernfs_remove_by_name_ns+0x3c/0x84 [] remove_files+0x34/0x78 [] sysfs_remove_group+0x40/0x98 [] cpufreq_governor_dbs+0x4c0/0x6ec [] __cpufreq_governor+0x118/0x200 [] cpufreq_set_policy+0x158/0x2ac [] store_scaling_governor+0x6c/0x94 [] store+0x88/0xb8 [] sysfs_kf_write+0x4c/0x50 [] kernfs_fop_write+0xc0/0x180 [] vfs_write+0xa0/0x1a8 [] SyS_write+0x40/0x8c [] ret_fast_syscall+0x0/0x48 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&policy->rwsem); lock(s_active#9); lock(&policy->rwsem); lock(s_active#9); *** DEADLOCK *** 6 locks held by sh/75: #0: (sb_writers#4){.+.+..}, at: [] vfs_write+0x180/0x1a8 #1: (&of->mutex){+.+...}, at: [] kernfs_fop_write+0x84/0x180 #2: (s_active#10){.+.+..}, at: [] kernfs_fop_write+0x8c/0x180 #3: (cpu_hotplug.lock){++++++}, at: [] get_online_cpus+0x38/0x9c #4: (cpufreq_rwsem){.+.+.+}, at: [] store+0x50/0xb8 #5: (&policy->rwsem){+++++.}, at: [] store+0x68/0xb8 stack backtrace: CPU: 0 PID: 75 Comm: sh Not tainted 3.16.0-rc3-00039-ge1e38f124d87 #47 [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x70/0xbc) [] (dump_stack) from [] (print_circular_bug+0x280/0x2d4) [] (print_circular_bug) from [] (__lock_acquire+0x18d0/0x1abc) [] (__lock_acquire) from [] (lock_acquire+0x9c/0x138) [] (lock_acquire) from [] (__kernfs_remove+0x250/0x300) [] (__kernfs_remove) from [] (kernfs_remove_by_name_ns+0x3c/0x84) [] (kernfs_remove_by_name_ns) from [] (remove_files+0x34/0x78) [] (remove_files) from [] (sysfs_remove_group+0x40/0x98) [] (sysfs_remove_group) from [] (cpufreq_governor_dbs+0x4c0/0x6ec) [] (cpufreq_governor_dbs) from [] (__cpufreq_governor+0x118/0x200) [] (__cpufreq_governor) from [] (cpufreq_set_policy+0x158/0x2ac) [] (cpufreq_set_policy) from [] (store_scaling_governor+0x6c/0x94) [] (store_scaling_governor) from [] (store+0x88/0xb8) [] (store) from [] (sysfs_kf_write+0x4c/0x50) [] (sysfs_kf_write) from [] (kernfs_fop_write+0xc0/0x180) [] (kernfs_fop_write) from [] (vfs_write+0xa0/0x1a8) [] (vfs_write) from [] (SyS_write+0x40/0x8c) [] (SyS_write) from [] (ret_fast_syscall+0x0/0x48) -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation