Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp167800lqi; Wed, 6 Mar 2024 13:18:28 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV1E2tjMFO1dOM/y/TbHzewvE9HO2oeSbUJlopwrcrvwCIlAaaGB3UYV9EqrGXL5JaNSl+MpR5TZNE/1psR6kzLmw8yivraXaavEMjkKQ== X-Google-Smtp-Source: AGHT+IFfWmOOnPPAEUqA9aGgiDAkQOrZr9R8K5SCqztGjxrx6p/PlPvou2T+6lwEctNnTK2DngP2 X-Received: by 2002:a05:620a:1103:b0:788:310c:f87e with SMTP id o3-20020a05620a110300b00788310cf87emr6728779qkk.5.1709759908099; Wed, 06 Mar 2024 13:18:28 -0800 (PST) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id br33-20020a05620a462100b0078833297e1asi5796695qkb.762.2024.03.06.13.18.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 13:18:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94589-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20230601 header.b=Mw1Vet8G; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-94589-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94589-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=REJECT sp=REJECT dis=REJECT) header.from=google.com 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 C1AFD1C210F5 for ; Wed, 6 Mar 2024 21:18:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 44DDE1B96B; Wed, 6 Mar 2024 21:15:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Mw1Vet8G" Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (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 9BF5818EB3 for ; Wed, 6 Mar 2024 21:15:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709759737; cv=none; b=PHi06YHWaZyu4TUcWZzmA8SVBzsKWwv90Y+8tLvotTCOvJN0UtEiwN3yxfoXaZxoOxqZ7Kw97PPRKo+x0dv/GESG9ld2YXw+sFrjrS+mTLucEG/EbGP+WE2eWjls80mhyeC9KEyraXgBFnVDZq8VpTi5ijGN1Gz9c6Q2lTIPAF4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709759737; c=relaxed/simple; bh=+l8m3POtAaDtB80yHDgkTD7KG7R8IqP1r+IYUdBueyY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WOwqSXkh4on1nDwZt7dMJPxYFhUroqqRSVGqS/cPcP5EiMQIHrDg0n7BMcvOU/Gd7TbtrT+po3Yfq3Ow0TqH1Xycs1DpI/XD6JwwCd8ZYFpiQMC3M3kX54OHB0lrgnsD11jMPjVInVY685TQQmkvCIFTV0PyceRjKOlh821DGcQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Mw1Vet8G; arc=none smtp.client-ip=209.85.160.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-428405a0205so9111cf.1 for ; Wed, 06 Mar 2024 13:15:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709759734; x=1710364534; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XzC+C2S5Etcf2Z/JbeuSZgXqxgIWaVv4J2sVk7ZKEIU=; b=Mw1Vet8GaEjAR37NCCWU79/XvpjY61JEVlsYVuM0bBxoWhcr7p3KI3TwYELi1G3AmH hUHx5EVmveFcA+PMrW0VKHzDfqdxEURqfonmPAdETQHm6DDvuIT+Kk6xYggmAsm9f2AM BQA7u7eCSAsKZcXJ3fKLkOVs8Y2dyEQKoxECKYmMnVGvhjTWCO4H19p/6xGYF3cUF/5O TQ1aj+zuY4EkbTjdBz75gLuHsI5GzqisOwCfUaI+PUkA9kMmlr+z4QiCwZkymMAi7iS4 hHJQV27bPht0Bk1ekYjQ19CIHeP4FMgPMc3rvaGdJAK41mwUy0Om7DOyLPnlJLlEWd0b /0/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709759734; x=1710364534; 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=XzC+C2S5Etcf2Z/JbeuSZgXqxgIWaVv4J2sVk7ZKEIU=; b=n50DY2rmAbzgGoa7MsOXk3GhSCVk+GZv0Q8pDfCeNoQKHv8KiPGEUtJpOWORX43u/s nnslp6nq7wyTJFzhWRaVjZUOEzX+Jvz95tHh8w0t7gS9oKHGTke440XE4Dsw9UtCStnC R06AHBUseY6bvAVH7TIMvJYxOtvol8Aci1qOECKtCGn++8+eb1fg8rUslMeW8pija/vE BNoCrgE7p0m8vK8bqLGlfS6jN/4yXA3n+K89MhYq56F5ykKnzHEvvyz8dncomeR3Kinr BwAJ1uTz0vbPR7PnUgfO6LgyEoDKj9f53OvLKqLshRxr2sMxzI4ovZQH7RRsbtXbYYYp eSiQ== X-Forwarded-Encrypted: i=1; AJvYcCXEIchqtOhQd20RPifjME3OL2QaHBiS+0MEsWIbPN3uCk0ArstC0XD7Gj6svU/3yCKvqcwE3bsa3uJZCiriqBEMfTwcEDC0X65LbVtJ X-Gm-Message-State: AOJu0Yy5pyf9S+FYrq6p2XXzrDoQQ3Pumib4Pk0TKK+X9Vw7OYIwE/KU jZ5JgfoVU42OmG3thIO5+E2+5Nw6ZCEspwi7Id7MSBC0uaF+QsSfn25PdodGyLBvz6+YQev6Wyv EI3Su+T2waPGJ8JUQ+ECmB0ZW0IhQttUC+akD X-Received: by 2002:ac8:5e0b:0:b0:42e:b7b2:2e99 with SMTP id h11-20020ac85e0b000000b0042eb7b22e99mr123586qtx.2.1709759734197; Wed, 06 Mar 2024 13:15:34 -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: From: Saravana Kannan Date: Wed, 6 Mar 2024 13:14:55 -0800 Message-ID: Subject: Re: [PATCH v4 1/2] driver core: Introduce device_link_wait_removal() To: "Rafael J. Wysocki" Cc: Herve Codina , Greg Kroah-Hartman , Rob Herring , Frank Rowand , 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 7:56=E2=80=AFAM Rafael J. Wysocki wrote: > > 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= used > > > > 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 th= e > > > > device itself is called. > > > > > > > > Nothing is present to provide some synchronisation with this workqu= eue > > > > in order to ensure that all ongoing releasing operations are done a= nd > > > > 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 re= moved > > > > (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 = raise > > > > 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 lat= e, > > > > 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 workque= ue > > > > 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= +e36wJEEnHDve+Avg@mail.gmail.com/ > > Well, I don't think this is a valid request, sorry. > > > The commit 80dd33cf72d1 introduces the workqueue and so some asynchrono= us tasks > > on removal. > > This patch and the next one allows to re-sync execution waiting for job= s 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 seri= es I'm okay with this too. I personally think it's better to list "Fixes: xyz" in all the patches that are needed to fix xyz (especially when there's no compile time dependency on earlier patches), but it's not a hill I'll die on. And if Rafael's suggestion is the expected norm, then I'll remember to follow that in the future. -Saravana