Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1936235lqo; Mon, 13 May 2024 03:03:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVFgUBBwDn00QtN/ucZAdgNI+hAzO1KRacIhs7YpleNVYCj4G54g0F3D692Pl7tDXWl1kMvnwVEuVhoeYbm/HDHNXyX8WtkzXjB9DFL+g== X-Google-Smtp-Source: AGHT+IHMW14tZyIeWJszRzpSrYCYg9NfMDS/b6SzKzVzXuDCwlDXsbY55ZxzcGWU+t8gykPh+Nhg X-Received: by 2002:a05:6300:8085:b0:1af:cfe9:9221 with SMTP id adf61e73a8af0-1afde1c580fmr12355610637.54.1715594636353; Mon, 13 May 2024 03:03:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715594636; cv=pass; d=google.com; s=arc-20160816; b=miYeNgDzsw+aEtiN8TpCH9aMNgQFCdRNjx4LGMiJQ67eE2llm6riqSd4Bsq0zYyoFY 0EU6F/mJMYZQJQMOqMv8SeoN6sUPQB7TbiBCBs9iJ+yUUjW51C+byesEEHXDWN1IVWr3 HpssfE156UMtFyoLVaaHszGuieI0kfnoKifhbzVMhyrqtLGlNSMYmNekVAz20s8J0pUr 06jSU96t3ROk5vW4wHwA11pWsz8V83VB2GAtWwnI1bbqK+ViKxJex718ojJ4tmlmpud/ OeOST3G0SKqbQW0kNz5gvs9otHY3wENsVcuP50S1Cw3rxi+E4RGKM4YW/InQIL2CZyRZ 84dA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=8YIU7mOSI1w6IQbECIUExQw5n5C4FYAdWKpkgSKgntk=; fh=bQlqM4dxJClNQA0xX5mpfXFh9jKlQj77DZ2dE4Ht6lU=; b=eRgdABVHay1R3C771+k0ii7jsONr8x6QezAMq3PQ4j3vqHwC05FFlPQuvKwpHne+sZ WW27yhEG9msZlLHXAvd+kHuXFLPCVqoQITCN4bzMwWfqFL4IKDF6bMSjKCd7oWIiFKum qV71dXFHzzAx4dIy7CcJ38iwpxyLYHlZt/mmaQimsbc5KnWKiUxZYuAaKNtfNhLcWtVL RRI5H/uFHXf2GCR7//jSQB64e3ZpFqGQuSoPMSD/KEUZYGVLILvMk+kS1bXF6dnkvRu6 wkIcpbDWxFUaYKc80jR9s7sh5Ute2ELgarB3l1kQtI927vNrZt3J1vU6sn++Zpl8AmXu SvAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-177435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0b9cf2e5si91576965ad.37.2024.05.13.03.03.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 03:03:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-177435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A3CEFB22D95 for ; Mon, 13 May 2024 10:02:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9ADB91494AE; Mon, 13 May 2024 10:02:16 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96F59148FEA for ; Mon, 13 May 2024 10:02:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715594536; cv=none; b=CDirvmCFYpGZSL776t0UpCuvkaChRbpiAHA/DeNsNwhsQgH9qmBIScc0Ri370mLfQy+lEZcHu+rdCCShPfxy04HDstaiHlOn+pyE6blVg59gCDpknFuLoGaKvKtwBM9uyXThUiI3Yob7rT0On3yYlhqdeWAEKQYcSVWytb64DIY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715594536; c=relaxed/simple; bh=SYcEIxfBwNPFTPph65lP/0ihilEfCBYGFhAT/9HGFBs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DyUrO+R8JZqf5YfXLUlJ9h0NKzJA+e5YUpEkEBUJWScEUEQjNuViBaOeHC/UDN68sOobB48duR+wNXjcyDOwtwm5U5T/ALiRyynPVBNvyXFa+d20flT8GmapOWTeBGM7lyLPHNfAr/Kvyc3NPG6KCnxHsAuE7cX5yq8lRIJ1e/g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D046B1007; Mon, 13 May 2024 03:02:32 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6B2793F762; Mon, 13 May 2024 03:02:06 -0700 (PDT) Date: Mon, 13 May 2024 11:02:04 +0100 From: Sudeep Holla To: Vincenzo Mezzela Cc: gregkh@linuxfoundation.org, javier.carrasco.cruz@gmail.com, Sudeep Holla , julia.lawall@inria.fr, linux-kernel@vger.kernel.org, rafael@kernel.org, skhan@linuxfoundation.org Subject: Re: [PATCH 0/2 v4] drivers: arch_topology: introduce automatic cleanup feature Message-ID: References: <20240501094313.407820-1-vincenzo.mezzela@gmail.com> <20240513081304.499915-1-vincenzo.mezzela@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240513081304.499915-1-vincenzo.mezzela@gmail.com> On Mon, May 13, 2024 at 10:13:02AM +0200, Vincenzo Mezzela wrote: > This patch series introduces the automatic cleanup feature using the __free > attribute. With this modification, resources allocated with __free are > automatically released at the end of the scope. > > In some cases, modifying the structure of loops is necessary to utilize the > __free attribute effectively. For example: > > ``` > struct device_node *t; > > do { > t = of_get_child_by_name(..); > if (t) { > > // some code here > > of_node_put(t); > } > i++; > > } while (t); > > // ^ > // | > // device_node here > ``` > > To use the __free attribute here, we need to move the declaration of the device_node > within the loop, otherwise the automatic cleanup is called only at the end of the > function, and not at end of each iteration of the loop, being it scope-based. > > However, moving the declaration of the device_node within the loop, we can no > longer check the exit condition in the loop statement, being it outside > the loop's scope. > > Therefore, this work is split into two patches. The first patch moves the exit > condition of the loop directly within the loop's scope with an explicit break > statement: > > ``` > struct device_node *t; > > do { > t = of_get_child_by_name(..); > if (!t) > break; > > // some code here > > of_node_put(t); > i++; > > } while (1); > ``` > The second patch eliminates all of_node_put() calls, introducing the __free > attribute to the device_node. > > > changes in v2: > - check loop exit condition within the loop > - add cleanup.h header > > changes in v3: > - split patch in two > - fix misalignment > - fix checkpatch warnings > - replace break with return statement where possible > > changes in v4: > - fix commit subject > - fix coding style > Looks good now to me. Acked-by: Sudeep Holla It is merge window now, so there is a chance that it may get lost. You may have to post it again at -rc1. Greg can then pick it up for v6.11 -- Regards, Sudeep