Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4175889rdb; Mon, 11 Dec 2023 10:57:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwM96XMJh/OgiGSIpy9+rbFsDfbGRhiXgHKXlZjMgJcGqidDA26XpMeJR5G430Vhq64DJp X-Received: by 2002:a17:902:bc84:b0:1cf:da41:7292 with SMTP id bb4-20020a170902bc8400b001cfda417292mr4312530plb.45.1702321025921; Mon, 11 Dec 2023 10:57:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702321025; cv=none; d=google.com; s=arc-20160816; b=DSks6VcAy2HDaP2y4O2QMCeI1WktKsenZRDDzVogSmT4XOkKBIpGBwYmk5TSc4WKn8 7msVmUL2zt+yUvdKDSMo1KhJ8I2o5sVqqS+ouEObdp35kiMi4WlKhvDjalOdrvMj7C3v +UbBI/p0uIBH5CD03XOceejrRGAwDojR/rFoO7h7VvMCqrl5say5jD7+VTSB8WFqLHDD 76nbeR5Kuyeu8A+iVE2qb0rvfC8tc3aOKhzzZ2nck91zWmcyV296NnKKKYZZd1PQG/OG MdKmVoVQiqYm/m5rqMsgmohQLGDSihsG1e5i3oihTdqlXOiCEG5z4lZb1zVeTOFMGrZ2 Xy6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=hktT8gcqcII+8mRlWxbm2Tcu4iOJi96Y1Rp33CXHSeg=; fh=xUybkfG92wTftWiA2YhPIEPNWyfvjVycLwk16+A8iZQ=; b=tdYt66dkPZBivZopUUW6czoY9oCP7rTYuELgc9kJ8soRbUf7DZjqxsWCVSsIX+ieww flP8DxY3mwHUwkT1xQ3G5RYL9O+seJbVcJ0QMbO5JJwj23GecWx4f6VDsGgR1+32uGe/ spTH7/7mjJhBHevuNeGh9rICrpGzJOHte9PYeJGntGmmQcGEZCDBcWEg3dsJlgd329mF tuSfuPmrhZlqQLEbULS+5jcrnx7Vq/jDhcCyaO6RdtE1Krl86t0kVQQPMlPaqlz7ViIO Nvd7iWwjs9zBwi68Oc7prnChU6tPaRVXhuFTDxdtEQT0wwQ5G3xYkj5HbKDCB2nr9TLC 9RZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id jj22-20020a170903049600b001cf69216445si6452513plb.392.2023.12.11.10.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 10:57:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CC28680A73C7; Mon, 11 Dec 2023 10:57:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344684AbjLKS4s convert rfc822-to-8bit (ORCPT + 99 others); Mon, 11 Dec 2023 13:56:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344513AbjLKRzR (ORCPT ); Mon, 11 Dec 2023 12:55:17 -0500 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B5BC139; Mon, 11 Dec 2023 09:55:06 -0800 (PST) Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6d9db92bd71so599770a34.1; Mon, 11 Dec 2023 09:55:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702317305; x=1702922105; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n5DEOgtWQGmkZPDn7q8GGAWjC29BJ9Cak4Iie+5uKU4=; b=MYsuzVVtoHz6N5IK8rbqy4BQ2+ZyNMx6lsm5bXiHGUnNftMoli6PyjFSJkDSAOePni IH0G1j8oCXRiHIT6f5Uj1NQdEMen4k/T//RS9rUx34nN0J6Djdi6tYqCPPcAJAOHTbd5 FHpk7itV97O8llPlCoMm6FoHCm9zxlmhn3wV1YxwjpNaogLijTScTh2kOvJ1sDkvr/TA EdxKDhDtguhsJ0SNiYHfEXqxIFCo4e53toUB1MnlzEBcI9MqdAeSA5cjuGSa6o2Hu/Fu 49/MtUsXRuJRPUostZ43sGW5psAZEOmCITxbKznFZ9kxUbpJAKHY+Y8WpUHksp5nAxii 4Srg== X-Gm-Message-State: AOJu0Yxh0Ujjq4NfIUk77IpMmx/a3UL64GqwIrnDrJU3SPp8y8T7WIn7 nJtiiXKILqGDbltEBOojtdAh+4cNMl7MvkLCVY4= X-Received: by 2002:a05:6871:2284:b0:1fb:648:5207 with SMTP id sd4-20020a056871228400b001fb06485207mr9535232oab.2.1702317305527; Mon, 11 Dec 2023 09:55:05 -0800 (PST) MIME-Version: 1.0 References: <1880915.tdWV9SEqCh@kreacher> <13414639.uLZWGnKmhe@kreacher> <0a0d5dd4-6b7a-428b-8ef1-bb6aff76fb51@linaro.org> <535558f8-096b-4917-92d2-b0defed42b15@linaro.org> In-Reply-To: <535558f8-096b-4917-92d2-b0defed42b15@linaro.org> From: "Rafael J. Wysocki" Date: Mon, 11 Dec 2023 18:54:54 +0100 Message-ID: Subject: Re: [PATCH v1 1/3] thermal: core: Make thermal_zone_device_unregister() return after freeing the zone To: Daniel Lezcano Cc: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Linux PM , Srinivas Pandruvada , Zhang Rui , Linux ACPI , LKML , Lukasz Luba Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Dec 2023 10:57:04 -0800 (PST) On Mon, Dec 11, 2023 at 6:35 PM Daniel Lezcano wrote: > > On 11/12/2023 17:42, Rafael J. Wysocki wrote: > > On Mon, Dec 11, 2023 at 5:28 PM Daniel Lezcano > > wrote: > >> > >> On 08/12/2023 20:13, Rafael J. Wysocki wrote: > >>> From: Rafael J. Wysocki > >>> > >>> Make thermal_zone_device_unregister() wait until all of the references > >>> to the given thermal zone object have been dropped and free it before > >>> returning. > >>> > >>> This guarantees that when thermal_zone_device_unregister() returns, > >>> there is no leftover activity regarding the thermal zone in question > >>> which is required by some of its callers (for instance, modular driver > >>> code that wants to know when it is safe to let the module go away). > >>> > >>> Subsequently, this will allow some confusing device_is_registered() > >>> checks to be dropped from the thermal sysfs and core code. > >>> > >>> Signed-off-by: Rafael J. Wysocki > >>> --- > >> > >> Definitively agree on the change > >> > >> Acked-by: Daniel Lezcano > > > > Thanks! > > > >> Would it make sense to use kref_get/put ? > > > > Why and where? > > Well it is a general question. Usually this kind of removal is tied with > a refcount It is tied to a refcount already, but the problem is that the last reference can be dropped from a thread concurrent to the removal one. The completion effectively causes the removal thread to wait for the refcont to become 0.