From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C56CDC433DF for ; Wed, 24 Jun 2020 15:33:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2283206FA for ; Wed, 24 Jun 2020 15:33:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NdGWSeUR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404490AbgFXPdG (ORCPT ); Wed, 24 Jun 2020 11:33:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404422AbgFXPdF (ORCPT ); Wed, 24 Jun 2020 11:33:05 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DD3FC0613ED for ; Wed, 24 Jun 2020 08:33:04 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id h5so2724380wrc.7 for ; Wed, 24 Jun 2020 08:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tjbKj2JJLg9M2F9CwUzFaqxTadc+FoDJkeC9qG6WPMU=; b=NdGWSeURe89L687lK6viNqICXEaDJjfaGLPwujuLMFiZJ1aDEkLa12K2oxn2S2WIEs hkB1pY5if8CE4WN9vmXx0Rt76OtQhGpcgWLvBb3iCCJ+YzMa0+YAGQrTgNniCwPaxZzD jLe8XHBoU9Ood6I/yiYOC9k11zyPlMZk0dUuHGDNPIwkrxoAHyHWrD4UMCeRIoTCkV1w o8esn5pXHLSpajx8K6CJdbsk9mY5zOIDBMYBBT8F6zfWUR3it3aKHnDkkm8x688uoyBW Fbr4PQoeJ2PrJiLw0o2n+X26nm/5PKbIN4tjB76F5y9DL3ehSR9YWAes/eksf5KbWiQ5 bL2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tjbKj2JJLg9M2F9CwUzFaqxTadc+FoDJkeC9qG6WPMU=; b=FW2losJ+GAiKBryXS95QGjDx0bJb6L0Gffibk598saaJqEvk9Nu2NxleRATu7N0WEZ 2aCHmj4Ob+MyfJBzGxmpCyDtWku3yEh0Sx8f6ECeIVnQ9pEpqh+SkeuqoNKXXMVlgyX2 qQ+Ty1rHWKsqnj6ia+NTyxFQ78MWnKYC5MHu25e/ZWjMJrGLaXjqpRBx3vAtU3SkH+/l a8casuVanVznlER/s56vEuPBZLMH+FfrAGuD9fikPxrbxfkE117v18/7mAqUDKqFl33w INdM9hHSggpN63F+JgJDr1kxaYDRPujIN2FABv0zGmwhYSML3KZwFSEio/UXmblNC1go REjg== X-Gm-Message-State: AOAM5311StovDwIq62IHLpmRVx7gaBDhpbiYOtvAKkTxt4jRkURfD8X0 Q0Of1KtpQiIy4P+W4I4Zju94dg== X-Google-Smtp-Source: ABdhPJzSLr689rNCk/afvTQhZdA+AJuwcms9tOdw/Vdl7nFAHHPTyyLyGmG/dH9YWD0knsSg2tqB1A== X-Received: by 2002:a5d:55cf:: with SMTP id i15mr20640246wrw.204.1593012783030; Wed, 24 Jun 2020 08:33:03 -0700 (PDT) Received: from google.com ([2a00:79e0:d:110:d6cc:2030:37c1:9964]) by smtp.gmail.com with ESMTPSA id z6sm4359909wmf.33.2020.06.24.08.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:33:02 -0700 (PDT) Date: Wed, 24 Jun 2020 16:32:59 +0100 From: Quentin Perret To: "Rafael J. Wysocki" Cc: Viresh Kumar , "Rafael J. Wysocki" , Arnd Bergmann , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , linuxppc-dev , Linux Kernel Mailing List , Linux PM , "Cc: Android Kernel" , Todd Kjos , adharmap@codeaurora.org Subject: Re: [PATCH v2 2/2] cpufreq: Specify default governor on command line Message-ID: <20200624153259.GA2844@google.com> References: <20200623142138.209513-1-qperret@google.com> <20200623142138.209513-3-qperret@google.com> <20200624055023.xofefhohf7wifme5@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 24 Jun 2020 at 14:51:04 (+0200), Rafael J. Wysocki wrote: > On Wed, Jun 24, 2020 at 7:50 AM Viresh Kumar wrote: > > > @@ -2789,7 +2796,13 @@ static int __init cpufreq_core_init(void) > > > cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj); > > > BUG_ON(!cpufreq_global_kobject); > > > > > > + mutex_lock(&cpufreq_governor_mutex); > > > + if (!default_governor) > > > + default_governor = cpufreq_default_governor(); > > > + mutex_unlock(&cpufreq_governor_mutex); > > > > I don't think locking is required here at core-initcall level. > > It isn't necessary AFAICS, but it may as well be regarded as > annotation (kind of instead of having a comment explaining why it need > not be used). Right, but I must admit that, looking at this more, I'm getting a bit confused with the overall locking for governors :/ When in cpufreq_init_policy() we find a governor using find_governor(policy->last_governor), what guarantees this governor is not concurrently unregistered? That is, what guarantees this governor doesn't go away between that find_governor() call, and the subsequent call to try_module_get() in cpufreq_set_policy() down the line? Can we somewhat assume that whatever governor is referred to by policy->last_governor will have a non-null refcount? Or are the cpufreq_online() and cpufreq_unregister_governor() path mutually exclusive? Or is there something else? Thanks, Quentin