Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2499939lqb; Tue, 28 May 2024 01:31:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWR9K+vCMuhGictIrN2hkrWTsgDhcN9PH4GSNImP5+Yj3jEsWJVJXP/ggp+mKZkHncRehW3mOahiJzLJyS8tP1z5gxtdn+EjZNx4uo7Sw== X-Google-Smtp-Source: AGHT+IEBFnqOxOpYP9ktvgaEVpG8P2CxM8402oEUc6aKYn61bfNhRNyHerNpchhxs5mrpU8uOLOf X-Received: by 2002:a05:6a20:7f8d:b0:1af:e649:6f4 with SMTP id adf61e73a8af0-1b212f874d9mr12191694637.57.1716885072791; Tue, 28 May 2024 01:31:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716885072; cv=pass; d=google.com; s=arc-20160816; b=sownAvgt36Fl8ynLp+Hg7+1/UAKQzqh/jH+MEzqjVdEFX9O7BIZJhzYdCojdH7Q8gZ 5ClugB5qhniD6SUC/HC6X1ZI0GJq41PMM04d/ydLjA1GYAwgidYUDeiV3+d+QuN/4qX5 yorN5wyC/dVleMz5ScWjqwKtQmqcQHBneW6kAT0zlqwcxuaZRKB2qzjDfQlrCLGXBmEe VF6s1FBbhUFRI/iOvdA+7FrbxsKtx8dJtl2Pytrf1Y0Zr5zfwvE8mevhYxmKt8vSsPUs pY+jKTNKiT6UnIBiJbgziYORjDag8PTLr2ag95MIQXyw+PWGIeu8KfffGfUPSKNK93we vFOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=pi6iHB0ijBhXGVK0cWOeQi30kiv2TjaO2ZCKvgQya/w=; fh=lyzL7WXTQYv7KdpktDkY6Y4aJwql2EbA9/ughyS8xpU=; b=Qs0wxXkLLdYvuOGtMWLM15TbW20SjSKxZHkUYk2/S6+UUP5WXOSKWkwAAgE5vbcM3n Spwekdrpj7zfXWwtwMXCP1/8iP/vy6hJu4QqhBb3eRQE8c4rUSnvMwVzoe2/oFa7/zcZ MDYAcgq4Fvf6Th3B5EAzeCchOwE1Id1ZKUi6U8SBUYF+5O/JSrhSzEKGpeBs98CoCqw0 +yYZi1SDyzLRF/A2mWfkNBTE7ZTrcJQQ2fWvAX8crP5Yrr3WeJVqN4FeGSf6/pYtohW2 sQspUWPE3VWAmHZPHHrx9dZIPU7t2sedZyvUOOQru8JXALwthHhaLhLNGRLSmgCXURkT zVqQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XFqcHI+9; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-191926-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f8fcfd806esi501774b3a.213.2024.05.28.01.31.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 01:31:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191926-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XFqcHI+9; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-191926-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1D4D2284ECC for ; Tue, 28 May 2024 08:23:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E860B13BC30; Tue, 28 May 2024 08:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XFqcHI+9" Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 6C1BE1DA22 for ; Tue, 28 May 2024 08:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716884622; cv=none; b=HRaJL5sIv+KvfatxI+ZJa4OeF2OSpz5VKmV/oj3NyAswgdtHp+FNJtFNxQUX3khE+/UqP6QIq6ozD5RYNPSNXeT+jKMagX8tS/uU7Um4EHdb0V/+uXWw2yX35y4NuIraM/HV7ov56vUUrvLCjK1FrmSxJFKytjdYmb6ke2sc5+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716884622; c=relaxed/simple; bh=62Yr6owy48A7Bd4/GXidveMcM9mRsbwypirqtcWfpzc=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=ta+SizsqWAW2hY/G9A6sWj4WagbhTvVopvoacqFufTAUYuSwXavuKbXEE2U1IPwlKdk1k5cYIPXJDuTd2UFDWgtItK3oy9nZ2LihgSdGlPbsBCUhgLTZldXC7lOJghjRFN57++yexiU9WEBMA974w+a4HkyKzK2sPT6RlHvilRc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XFqcHI+9; arc=none smtp.client-ip=209.85.208.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2e95a75a90eso5047631fa.2 for ; Tue, 28 May 2024 01:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716884618; x=1717489418; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=pi6iHB0ijBhXGVK0cWOeQi30kiv2TjaO2ZCKvgQya/w=; b=XFqcHI+9OSJ7LuQ+vOXm2z7hHAxa7p0IiaUJ29eeKMnH9iWPbklS5jhj4TazX9yqkl QqLD7jU6BpASlly6/nCpU3/BPmDCo4udt2ptf8wcvR14BXbC15xnq2dLAQEiTpVUbLsU W2pZtd2GLNjpgo7f3du0/b4TTGik06dMj5z4R6+92JU78rG26SIsHEK2UmvSmLPtkRFV JI1xhPQvgrJTJun5A0GChWEgdhQLLRhdjctaOXv5nFGs8GoZe7+DV+chTnItKWE5+Z55 VPFWg6ih0OedMeHlqu6VFAvF7H/N0Uav1S6AAIGIzGaM/ynap1LW9YXnveR1UB5MiEot 6hNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716884618; x=1717489418; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pi6iHB0ijBhXGVK0cWOeQi30kiv2TjaO2ZCKvgQya/w=; b=wIJKyXVpg8K+B9bR45lbsfmrspOhKbnyJ2wKvjg5B7ratO0Qk7aOaPkr3U/doQ80ug RI1MoHGJ5hLekHD0AqkDLnfawbjt0oo0tlK2T+2W3zqt/cNbUqJrSi+plRem2VXDdPu4 bqL0a3fisoe2TLbveYzKa84rEB59bsxoQj6d0AupzYblB8s/9dVyhGjtn38Z6t5vF5B0 j3dPd/VTFwUs5cHo2kXLw7KvsGY5w//aRFbyTPsX/Z2O6J7KBc2KSZQt1T6ZjLF/Ky7s AjaFOO+1i4utgMAVtNkvIZ7tjtuxEbfk8H+A572/S9kVKKWJug983xTuPmd7x08bumXS 2Yyw== X-Forwarded-Encrypted: i=1; AJvYcCXsl3IO9rJdS2ZDvlnmGB6ztEPi3VO4OdwDs8nsarGoz5ydmPOSXF0gCVJje0MJKZFLFpySrn42OSOzrZk1biqOcyz/LtnzQU07Xali X-Gm-Message-State: AOJu0YzOa0pUe2LDKB95mx5cCcKwexxPV5fvxvL+08iD4lC40jlnk6yH wnnvrD7+SV2aMwTRcVTzr//f1zyhv/GWrmW+o1IfB1bE9wZo/fx9 X-Received: by 2002:a2e:6e12:0:b0:2e7:5bd4:acd6 with SMTP id 38308e7fff4ca-2e95b0bd9b9mr67528011fa.13.1716884618149; Tue, 28 May 2024 01:23:38 -0700 (PDT) Received: from ?IPV6:2001:b07:ac9:e686:e225:3764:719:c2ec? ([2001:b07:ac9:e686:e225:3764:719:c2ec]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3557a08cc1bsm11113020f8f.45.2024.05.28.01.23.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 May 2024 01:23:37 -0700 (PDT) Message-ID: Date: Tue, 28 May 2024 10:23:37 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Vincenzo Mezzela Subject: Re: [PATCH 0/2 v4] drivers: arch_topology: introduce automatic cleanup feature To: gregkh@linuxfoundation.org Cc: Sudeep Holla , javier.carrasco.cruz@gmail.com, julia.lawall@inria.fr, linux-kernel@vger.kernel.org, rafael@kernel.org, skhan@linuxfoundation.org References: <20240501094313.407820-1-vincenzo.mezzela@gmail.com> <20240513081304.499915-1-vincenzo.mezzela@gmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 13/05/24 12:02, Sudeep Holla wrote: > 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,t > Sudeep Hi Greg, hope this message finds you well. I wanted to kindly follow up on the patch [1] I submitted to introduce the __free attribute in drivers/base/arch_topology.c Thanks, Vincenzo - [1] https://lore.kernel.org/lkml/20240513081304.499915-1-vincenzo.mezzela@gmail.com/