Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp1159482lqs; Wed, 6 Mar 2024 07:57:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVFhAiAIw+fuwmZJCVS+gBTMaif8YwBFmIi7IZBHMgFiNw9k84Bufp111vzqqpfd1cME2rg5SSh8CUeLTMpI4+HBau7CRB+7MVKH5lQdg== X-Google-Smtp-Source: AGHT+IF1tqPh4I8jgSQf0922L+zRdmH1ReUndK80d9fX/wMb41ds27VyzAClGOGDml3e06iQ3Mth X-Received: by 2002:ad4:4d0a:0:b0:690:99fe:3c92 with SMTP id l10-20020ad44d0a000000b0069099fe3c92mr1135217qvl.31.1709740664191; Wed, 06 Mar 2024 07:57:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709740664; cv=pass; d=google.com; s=arc-20160816; b=zaU5o+lXZmEFkSQQreUZjX2E9RSfogJ/NkC6Mmc/kulB1AZ2bGzWHZ8RbA3S7ZQOlW J3hTmCdhlPZ2OGPwQ+23V4YhZ6YvBV8LImtQBF9T67irXw424GxB48YRj+iWj2i3J9nR 90l82+U124rKhK64/arK+Zw4r9kwDwowoiWXfm67xoU/jKeHBD7I7syaqnoIM2gMVPS4 eCYKumUiKVJNGqwIxHP/F22YDyDxkdVSQ90lCdlT2iSZsAMEnE83wwGjbTsD6Q7CtHXZ z/oZk54YJHCOLG5gqao+6wc6n0US9m3s0Zhxz9/ux+utkHbrtuMbfU2HJ0jorIGPiTA9 18VA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=rRuYu3pgVDn4yl5odBwmAdoeGMF5J7JUGXQ//zks9Lo=; fh=VcSstZX118tm9RY21iSzdBHSNabHPtE9uU/15l3Aa8o=; b=rOnolrZF3camtcMDgc8Dxlh1u6nb9vIko/9FBROugENA6VTrEf9yz0UKut4A+g7dWP QsOLv3GR+b8umBYwUQx0LFoH+9Zn+IMRU5OesyHlfqMUqSpPlyvNHpRqU0qWPE6E+SNE CjayLHVFq/KLrqgeU+pSFhlergWZsYHihpuAnru4eDHES2npwZYAsJrx80Z0Cw1eFIZp lEJVEkJoeHAIQvuui5o9uyouGiIj5KexEKQmfArj5NVW2N27TXvZBNtlIqJyjT+ISYXR qQAAZFGVymdbwxdZTXWYsCI7YEiqxgfpotWafHRxgzvx87/Q2H3go+u4ve31+OGguUmZ YAgw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-94208-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94208-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ge13-20020a05621427cd00b006902d35afc0si14416194qvb.259.2024.03.06.07.57.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 07:57:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94208-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-94208-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94208-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D81E11C221BC for ; Wed, 6 Mar 2024 15:57:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2811C1361CF; Wed, 6 Mar 2024 15:57:02 +0000 (UTC) Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14C6460912; Wed, 6 Mar 2024 15:56:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709740621; cv=none; b=FNbQJgz2dVLIbhozGAK2rVbiNFE7Wy2jDLc79e6mgJfQxdow06WtftK0E3tVNc3f8zhkHOXZeZzgN6NUBym3Wrpr5kiOZ+EyQEmAtNShRnFbLuwVh3U2JCqvw3htDT9uu0J9TLT3O6K3Ad2jNxW0gwCaFs/h6oNI79zxntN3miM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709740621; c=relaxed/simple; bh=4tghISU+9PtSjWtX/KooJvAfp+afRTcd2Wim7+281EQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=V3fnhn+SqQpRPkCjVpcJk7kKElfpovxu33CdVAQJWT500Dpd5VPSseM4T7eJ3LfSrGWtxXd5+Gzl6uFjlKAs3i9VGnXo/0rFSToiAT6Fw+xLtgU7gnI1CeRPo/hbl3InZRhNsvXhO64u+d0kY04ifh3PdX6sgyeAMQQZPupY3Qw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-220ce420472so1347446fac.1; Wed, 06 Mar 2024 07:56:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709740619; x=1710345419; 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=rRuYu3pgVDn4yl5odBwmAdoeGMF5J7JUGXQ//zks9Lo=; b=caIkFuJjjXDO/al/axSusjbPiXmNNt3mzhGkUieoiXW90xWxq0v/0W4pKvI2xfUQRM a7YOFhY6kd2MM+3+NoDaVLgbSKaxXp4+eMveJLzae5phMVGBbgstmYUuDUvWh48da8jl x8MOjDFepXKxQXs4DXjRt10wz5zczX/XeUE6buQZTjVIdPVDRWuds8aI2JjaU2Id1Zf8 v6r5N/TvY3Pxhhwna0Uj9Momr7AOcggC+hHdIOqX7FcgSEmKGsDDZhEXPzs9VJkabcjv YRbBShnhkblHMXs498jj53GpeLbFaGxwzEcYkg+PtjPZPab2Yr5QCPO91KETeZC6Y03i bjWQ== X-Forwarded-Encrypted: i=1; AJvYcCW2T2/rJcCyAMW3lFrqSlJ6aK8MN8aUqRIu7CDisTdZZyItHdpfyO+l99n7bf9rR+cl5Smx649y2fXnwzd52XyyUu43/mpZsj0RegLuRhlB2sOqsDzqS4S/FXG8KKv3AGW/ppe+DsrDsiJEG6Z4v4QlH361jFzLIHJLdTD+2NhJAw== X-Gm-Message-State: AOJu0YyF3NvROZjWzy/q6GkfQeLoa64NEaQB7naVxrCWzVpJY+n8I1P3 wH1gQ1LFEWTZ6ktQqiMD3alGTMy7waMsNYu5TXsSEQHKXsbK+UxwdDN60u240/3rDffc1+uqtj8 YloACJiYIHU84iKAu7bt86VecMhI= X-Received: by 2002:a05:6870:d681:b0:21e:ad52:3029 with SMTP id z1-20020a056870d68100b0021ead523029mr4049265oap.0.1709740619125; Wed, 06 Mar 2024 07:56:59 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240306085007.169771-1-herve.codina@bootlin.com> <20240306085007.169771-2-herve.codina@bootlin.com> <20240306162447.2a843a11@bootlin.com> In-Reply-To: <20240306162447.2a843a11@bootlin.com> From: "Rafael J. Wysocki" Date: Wed, 6 Mar 2024 16:56:47 +0100 Message-ID: Subject: Re: [PATCH v4 1/2] driver core: Introduce device_link_wait_removal() To: Herve Codina Cc: "Rafael J. Wysocki" , Greg Kroah-Hartman , Rob Herring , Frank Rowand , Saravana Kannan , Lizhi Hou , Max Zhen , Sonal Santan , Stefano Stabellini , Jonathan Cameron , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Luca Ceresoli , Nuno Sa , Thomas Petazzoni , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 6, 2024 at 4:24=E2=80=AFPM Herve Codina wrote: > > Hi Rafael, > > On Wed, 6 Mar 2024 13:48:37 +0100 > "Rafael J. Wysocki" wrote: > > > On Wed, Mar 6, 2024 at 9:51=E2=80=AFAM Herve Codina wrote: > > > > > > The commit 80dd33cf72d1 ("drivers: base: Fix device link removal") > > > introduces a workqueue to release the consumer and supplier devices u= sed > > > in the devlink. > > > In the job queued, devices are release and in turn, when all the > > > references to these devices are dropped, the release function of the > > > device itself is called. > > > > > > Nothing is present to provide some synchronisation with this workqueu= e > > > in order to ensure that all ongoing releasing operations are done and > > > so, some other operations can be started safely. > > > > > > For instance, in the following sequence: > > > 1) of_platform_depopulate() > > > 2) of_overlay_remove() > > > > > > During the step 1, devices are released and related devlinks are remo= ved > > > (jobs pushed in the workqueue). > > > During the step 2, OF nodes are destroyed but, without any > > > synchronisation with devlink removal jobs, of_overlay_remove() can ra= ise > > > warnings related to missing of_node_put(): > > > ERROR: memory leak, expected refcount 1 instead of 2 > > > > > > Indeed, the missing of_node_put() call is going to be done, too late, > > > from the workqueue job execution. > > > > > > Introduce device_link_wait_removal() to offer a way to synchronize > > > operations waiting for the end of devlink removals (i.e. end of > > > workqueue jobs). > > > Also, as a flushing operation is done on the workqueue, the workqueue > > > used is moved from a system-wide workqueue to a local one. > > > > > > Fixes: 80dd33cf72d1 ("drivers: base: Fix device link removal") > > > > No, it is not fixed by this patch. > > Was explicitly asked by Saravana on v1 review: > https://lore.kernel.org/linux-kernel/CAGETcx9uP86EHyKJNifBMd23oCsA+KpMa+e= 36wJEEnHDve+Avg@mail.gmail.com/ Well, I don't think this is a valid request, sorry. > The commit 80dd33cf72d1 introduces the workqueue and so some asynchronous= tasks > on removal. > This patch and the next one allows to re-sync execution waiting for jobs = in > the workqueue when it is needed. I get this, but still, this particular individual patch by itself doesn't fix anything. Do you agree with this? If somebody applies this patch without the next one in the series, they will not get any change in behavior, so the tag is at least misleading. You can claim that the next patch on top of this one fixes things, so adding a Fixes tag to the other patch would be fine. There is an explicit dependency between them (the second patch is not even applicable without the first one, or if it is, the resulting code won't compile anyway), but you can make a note to the maintainer that they need to go to -stable together. > > > > In fact, the only possibly observable effect of this patch is the > > failure when the allocation of device_link_wq fails AFAICS. > > > > > Cc: stable@vger.kernel.org > > > > So why? > > Cc:stable is needed as this patch is a prerequisite of patch 2 (needed > to fix the asynchronous workqueue task issue). Dependencies like this can be expressed in "Cc: stable" tags. Personally, I'd do it like this: Cc: stable@vger.kernel.org # 5.13: Depends on the first patch in the series