Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp338407iob; Fri, 13 May 2022 02:53:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBeI90DlECKMNwQ2Eite81ZD5n7tUr/dnF9BDhr+NI9U4NETOoWTPx3TKcaUSQFNIT4xFw X-Received: by 2002:a17:906:2b06:b0:6f4:7e76:c855 with SMTP id a6-20020a1709062b0600b006f47e76c855mr3589838ejg.78.1652435634139; Fri, 13 May 2022 02:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652435634; cv=none; d=google.com; s=arc-20160816; b=HhOVDl0+ouXM+2Fm4JKtukcb1Sj5Q9dz1/ONkhbBQ/wN2BIVqAqOJ9tDx8UnDWcb+4 N0gHHw3pmIasNxhJPKkQWj07FWugL2zlPZ8ViKIBX1A15/6JQps9Joos7isMB1eYRP3b 6P5R3Bh40TwIWmcauhSHCUBWuF0yBEeZN/n/EkzOU1R6+MMEUrxe3z6pZ+ovowkIQ/mA +D36uf9wnubW+JnHO6wUkoo9hJjEtBh6ZZrpnMS3hoc9GJq39GIpHd+tkYBePAq2+kYf JhoAY9fv/le+fyg+q2VXN6JzidiiMaim2RAcs/OrVsn8JN3TtQvOGY3UlxbjPsUFJLQb 8VsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=WIZMHJ5xRJacnsB6/o2E9laJl0A/k8C1YscKZGNG7WM=; b=0ruZPR/MJ+ChY3cKTLOBC7gzgCq2eOhQPSaYsjUmbdlC2rOzyK14czCFaKovOxPnZB nqtTqKX/tcWmzEcf63TJWEFjsJ3EhrWo40YrNUNpwcF5IDf9lP5UMAwYtfPN6+OmnQCM BpKykQQ3cerGO2vco3SyyC9TO391IIN37WD9enz0q2VMn4HWeit1lkAyZ8DSqeSPA9zU RDpx09ptZ3Nx5O7hkQeTmE8yJ5a3BNqU92jKhOj5xGFh76cOE6y6T8+Eo4JrQtRA+It0 ApJjoDhXtcG0UJVZgolN7sMw0uSS/fSGEiHNBGTzvt6YFzI1wY/l3BRnQ3P8TvCIyxrx Ovcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CDwaq7yh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk20-20020a1709077f9400b006f86136d0afsi1846853ejc.294.2022.05.13.02.53.28; Fri, 13 May 2022 02:53:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CDwaq7yh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350600AbiELG47 (ORCPT + 99 others); Thu, 12 May 2022 02:56:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238889AbiELG43 (ORCPT ); Thu, 12 May 2022 02:56:29 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D2821836F for ; Wed, 11 May 2022 23:56:27 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id l11-20020a17090a49cb00b001d923a9ca99so4074250pjm.1 for ; Wed, 11 May 2022 23:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WIZMHJ5xRJacnsB6/o2E9laJl0A/k8C1YscKZGNG7WM=; b=CDwaq7yh1rz+5ZXUtvYAmjK5GoGl0YKf9usiA8Qr0ncf55O2ooNJCUldcC4OWNITMD Bi54+J2lepaOCMCr7j49UhXpQm39vVkbhACXPmy7rxvh+A57/qp7gARCu767qWcqEPm4 cTsdp4sQDW5zjc9rzS1fFS/Z+EgC3Hyx1Zl9WQjJ6NXoFPPikQbKtGryud/o2IPcDC2C bYTlLfyJSJjG+e1cmbp4TUxIn/Zvh82xBUn1cZLzwKSVuIYAwJ0ByDFq4L3TcG7dWypc +jCHNYeum0ecMEPenZvIgJ4WTaRiv6AV0vpRaWJBuChT8Zts+6fIuLb2H0IpFrWLUjF/ bH4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WIZMHJ5xRJacnsB6/o2E9laJl0A/k8C1YscKZGNG7WM=; b=sD81pLwBx8TQL0C10m67APx8pOJ+C1wdychVIjFfbi65baiyLJ0G/9jr4ZPdya9KsW HmPYAZy1Ddwyo9nC8xOpcVM8gqvYE6NmIdBNP/x7WBD8eDylklDAs14CMzQ1geruZAdV ClO45bFyYtBHb955wgu5eGbLJGYcHL0/6sU+jZLSzuOYUrRqXXYrJdZ1fSm580nhr4qc XfIiTnm2WkeZw7nXEcAnXhnZUpIxkSC/pgmNmDUFIl9Gr+nMmtl75DisnYZMa4hU0er1 RAJnEqiqZt2jlFhrTMB+3AOH9DoRr8On5gJbSamOIRKT75y93TLSK/pEtTbZQ/FfS8eR jpyA== X-Gm-Message-State: AOAM530s9XM8L4xv6Wf7rIoztF/+uFFBCsxgSt48lSQVc6NHw3qtKeoE aTWmsCA7hyvM2jrHzQQH7Fk42w== X-Received: by 2002:a17:903:1108:b0:156:73a7:7c1 with SMTP id n8-20020a170903110800b0015673a707c1mr28578721plh.101.1652338586874; Wed, 11 May 2022 23:56:26 -0700 (PDT) Received: from localhost ([122.162.234.2]) by smtp.gmail.com with ESMTPSA id e4-20020a636904000000b003db141a5f26sm1110175pgc.1.2022.05.11.23.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 23:56:25 -0700 (PDT) Date: Thu, 12 May 2022 12:26:23 +0530 From: Viresh Kumar To: "Rafael J. Wysocki" Cc: Schspa Shi , Linux Kernel Mailing List , Linux PM Subject: Re: [PATCH v3] cpufreq: fix race on cpufreq online Message-ID: <20220512065623.q4aa6y52pst3zpxu@vireshk-i7> References: <20220510035259.5ep52sgahd2a6rie@vireshk-i7> <20220510154236.88753-1-schspa@gmail.com> <20220511043515.fn2gz6q3kcpdai5p@vireshk-i7> <20220511122114.wccgyur6g3qs6fps@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-391-311a52 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11-05-22, 15:19, Rafael J. Wysocki wrote: > On Wed, May 11, 2022 at 2:59 PM Rafael J. Wysocki wrote: > > > Hmm, I don't think depending on the values of policy->cpus is a good idea to be > > > honest. This design is inviting bugs to come in at another place. We need a > > > clear flag for this, a new flag or something like policy_list. > > Why? Because it doesn't mean anything unless we have code elsewhere which checks this specifically. It should be fine though after using policy_is_inactive() in show/store as you suggested, which I too tried to do in a patch :) > > > Also I see the same bug happening while the policy is removed. The kobject is > > > put after the rwsem is dropped. > > This shouldn't be a problem because of the wait_for_completion() in > cpufreq_policy_put_kobj(). It is known that cpufreq_sysfs_release() > has run when cpufreq_policy_put_kobj() returns, so it is safe to free > the policy then. I agree to that, but the destruction of stuff happens right in cpufreq_policy_free() where it starts removing the policy from the list and clears cpufreq_cpu_data. I don't know if it will break anything or not, but we should disallow any further sysfs operations once we have reached cpufreq_policy_free(). > TBH, I'm not sure why show() doesn't check policy_is_inactive() under the rwsem. I agree, both show/store should have it. > Moreover, I'm not sure why the locking dance in store() is necessary. commit fdd320da84c6 ("cpufreq: Lock CPU online/offline in cpufreq_register_driver()") -- viresh