From patchwork Mon Jul 23 17:49:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10540655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3FC8184F for ; Mon, 23 Jul 2018 17:50:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD62A26223 for ; Mon, 23 Jul 2018 17:50:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F85226242; Mon, 23 Jul 2018 17:50:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44A9126223 for ; Mon, 23 Jul 2018 17:50:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388125AbeGWSwT (ORCPT ); Mon, 23 Jul 2018 14:52:19 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53250 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387994AbeGWSwT (ORCPT ); Mon, 23 Jul 2018 14:52:19 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E850A7264E; Mon, 23 Jul 2018 17:49:59 +0000 (UTC) Received: from llong.com (dhcp-17-175.bos.redhat.com [10.18.17.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1F83178B8; Mon, 23 Jul 2018 17:49:57 +0000 (UTC) From: Waiman Long To: "Rafael J. Wysocki" , Viresh Kumar , Thomas Gleixner , Peter Zijlstra , Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, "Paul E. McKenney" , Greg Kroah-Hartman , Konrad Rzeszutek Wilk , Waiman Long Subject: [PATCH 0/2] cpufreq: Fix a circular lock dependency problem Date: Mon, 23 Jul 2018 13:49:37 -0400 Message-Id: <1532368179-15263-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 23 Jul 2018 17:50:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 23 Jul 2018 17:50:00 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'longman@redhat.com' RCPT:'' Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patchset works around a circular lock dependency issue in the cpufreq driver reported by lockdep. The two locks involved are the cpu_hotplup_lock and the reference count of a sysfs file. The cpufreq_register_driver() function uses the lock sequence: cpus_read_lock --> kn->count Whereas the cpufreq sysfs store method uses the sequence: kn->count --> cpus_read_lock This is not really an issue as a shared lock is used on the cpu_hotplup_lock. However, the lockdep code isn't able to handle shared locking. So one way to work around this is to define a cpus_read_trylock() function and uses it in the store method instead. Waiman Long (2): cpu/hotplug: Add a cpus_read_trylock() function cpufreq: Fix a circular lock dependency problem drivers/cpufreq/cpufreq.c | 16 +++++++++++++++- include/linux/cpu.h | 2 ++ kernel/cpu.c | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-)