Message ID | 20230912085541.13682-2-brgl@bgdev.pl |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp334741vqx; Tue, 12 Sep 2023 04:23:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyOWDLHwz2WccQCFw0EN5/1mzbd76oo+qeEDoUBSyj6+SDqRwPLw+gXRUO3ZDmDZOyO7Iv X-Received: by 2002:a05:6a00:2d27:b0:68b:ff3b:e140 with SMTP id fa39-20020a056a002d2700b0068bff3be140mr11251014pfb.8.1694517838921; Tue, 12 Sep 2023 04:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694517838; cv=none; d=google.com; s=arc-20160816; b=VtYYzEDQBGNSwYXzyjNpk3DD/4mI7bsk3WJHu2/mAafav7DTxKGQrRQ+7SwSdRlz8H iaReE1sUfeub/W8N7ikadhJiYguaoz4N75j+UgRWRcZEJ6mS+Lg5j8zwMefVmUDvt1cv nXcEP0MjYNg3Byq2px8kBeBdHrpMbPYeHOdoOJL+p8wlgmp0Kzx27mPQuWIWW5vIvlO/ VKXKtRlgebHMi/l6wfZy2r9g5iwQb9NzSSnsz/3dBe7JcvrlCoCkxg4QKoPuhd/Pnxjj lcFtDOfaEegjlHfWhvIJ0KRI9bAjkoupuoHYOFR2jXyu2ZNy6sIAtOdKSC2qP2cNLk7l 3FoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UGE8+aaEWV5mHsdN/XyuIXsk7ZbIHUwF0zjQXkbFuiY=; fh=jelMaxxYL7iVN5WTJYLdEcOSQCZkPWCTA7Z8F6/jemw=; b=CtoNdlhllq31D732y9aUgr/iB2ultZ2DjxwiApqFFBbtbPst9fBCVL0Ku/ZRwibBT9 jLGV3G/Cl+2x9yTNSxlCwb1h7BTuK8nCB/LKw7xAtMsH8bUmqHcB7V81ruNo0q6eRju9 ji3Axf+N4bq+8sTvjzi0K8S4+uQSQ+iKk/3EAwfgl02LSnZtB6DosTpT6idcBXvbc1qn P7Herf7Pa6yCU/pny13j4NPf2Inplm3s2Ua8v1BZjlfNEwb2EvFk9tMzH1LH3bfpD3Nz bPrsYL3FRHxMuBV+UO20nMrSDnAArvNZXimLuYR8ev3KZU2DBF6I9o9eYNt8d7CeSiQf jodQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=PPBZqTjs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id be25-20020a056a001f1900b0068fd0b1bd61si2326845pfb.50.2023.09.12.04.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 04:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=PPBZqTjs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 2CA2B8119075; Tue, 12 Sep 2023 01:56:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233064AbjILI4I (ORCPT <rfc822;pwkd43@gmail.com> + 38 others); Tue, 12 Sep 2023 04:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233048AbjILI4F (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 12 Sep 2023 04:56:05 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E47EE7A for <linux-kernel@vger.kernel.org>; Tue, 12 Sep 2023 01:56:01 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-401ec23be82so59284255e9.0 for <linux-kernel@vger.kernel.org>; Tue, 12 Sep 2023 01:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694508960; x=1695113760; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UGE8+aaEWV5mHsdN/XyuIXsk7ZbIHUwF0zjQXkbFuiY=; b=PPBZqTjs9fBExOCIh0mpM57vyyCAnaBol8M4+06l6SXloJ3jBVthtC723YLf1CqPoM ON4zl92Sf4zbkAMC1yY3i7Bvm98q3mkqBC8SO5wHjP84zABOzeWmqwW7WqEkiDn2M9re ZmVXj3aYVawQvV1uhFZAXETGqrysz0MkxHq7xQsQrjB26/vLg73YoUXtodNK+J4c9nHF XrktqzZNZctJ/M8eb8tXaF6cvlpY/39tNjbhREqRhVL+jC0Q6Ky2vijvQXpkP2JV8CA6 8w0P3qreIg5YGkQGq5SEmsOrdjaZQvAAxNtFCHpaVeyJohLNJXDVvFkUfVmPV//97k/T /CgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694508960; x=1695113760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UGE8+aaEWV5mHsdN/XyuIXsk7ZbIHUwF0zjQXkbFuiY=; b=Yu8LHp+B2/BG943g7fMrJ8KFjx0klctLhvzMCo+UWCenZ69f19s4WDfQ2jxlisiFlL E3KYBAskK8q5G3qNpdz44BHpX9j0RkKDgob/yI0cjoHnVQQIoVP0zo6o9qdod+LfJ156 wIzydSLtPAmTcDIYXhX5UbeFTygg+uTFnaPUtRzsbLxHfW7T6fthWMhO5b/keG+racMo lNkXsxmZlcII4KNTC7uLMokkBG5r67v9UoU40tYaaRu0Ld/S+V7zf5lNRNnP1rb5cq23 MZNjbv4OIa8JTKyE7MiaXvkN8MauuvGZgcXJ+X7M/TQm186zM/F0I1kzrfDiLcis7oxG qt9Q== X-Gm-Message-State: AOJu0YwjUFn+QLZvqDuWkYM1+xKkmVr57rG9CEizw21h+BwyyF22jiH0 AK5tkWJ06bics+fypDJXdHInGQ== X-Received: by 2002:adf:e78c:0:b0:314:1b4d:bb27 with SMTP id n12-20020adfe78c000000b003141b4dbb27mr9815432wrm.64.1694508960129; Tue, 12 Sep 2023 01:56:00 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:907f:4cd7:f0ae:6b2a]) by smtp.gmail.com with ESMTPSA id d6-20020adfef86000000b00317ddccb0d1sm12310028wro.24.2023.09.12.01.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 01:55:59 -0700 (PDT) From: Bartosz Golaszewski <brgl@bgdev.pl> To: Yury Norov <yury.norov@gmail.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Rasmus Villemoes <linux@rasmusvillemoes.dk>, Thomas Gleixner <tglx@linutronix.de>, Marc Zyngier <marc.zyngier@arm.com> Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Subject: [PATCH 1/4] bitmap: define a cleanup function for bitmaps Date: Tue, 12 Sep 2023 10:55:38 +0200 Message-Id: <20230912085541.13682-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230912085541.13682-1-brgl@bgdev.pl> References: <20230912085541.13682-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Sep 2023 01:56:27 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776827962466257662 X-GMAIL-MSGID: 1776830737689428424 |
Series |
genirq/irq_sim: misc updates
|
|
Commit Message
Bartosz Golaszewski
Sept. 12, 2023, 8:55 a.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Add support for autopointers for bitmaps allocated with bitmap_alloc() et al. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> --- include/linux/bitmap.h | 3 +++ 1 file changed, 3 insertions(+)
Comments
On Tue, Sep 12, 2023 at 10:55:38AM +0200, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > Add support for autopointers for bitmaps allocated with bitmap_alloc() > et al. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > --- > include/linux/bitmap.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > index 03644237e1ef..ba8c0d733842 100644 > --- a/include/linux/bitmap.h > +++ b/include/linux/bitmap.h > @@ -6,6 +6,7 @@ > > #include <linux/align.h> > #include <linux/bitops.h> > +#include <linux/cleanup.h> > #include <linux/find.h> > #include <linux/limits.h> > #include <linux/string.h> > @@ -125,6 +126,8 @@ unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node); > unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node); > void bitmap_free(const unsigned long *bitmap); > > +DEFINE_FREE(bitmap, unsigned long *, bitmap_free(_T)) So now it doesn't do weird "if (_T) bitmap_free(_T)". Have you got any feedback from Peter for that? My point is that if the above is correct, all the following declarations need to be revisited: yury:linux$ git grep DEFINE_FREE|grep if include/linux/cleanup.h:25: * DEFINE_FREE(kfree, void *, if (_T) kfree(_T)) include/linux/device.h:1058:DEFINE_FREE(device_del, struct device *, if (_T) device_del(_T)) include/linux/device.h:1228:DEFINE_FREE(put_device, struct device *, if (_T) put_device(_T)) include/linux/mutex.h:224:DEFINE_FREE(mutex, struct mutex *, if (_T) mutex_unlock(_T)) include/linux/rwsem.h:208:DEFINE_FREE(up_read, struct rw_semaphore *, if (_T) up_read(_T)) include/linux/rwsem.h:209:DEFINE_FREE(up_write, struct rw_semaphore *, if (_T) up_write(_T)) include/linux/sched/task.h:164:DEFINE_FREE(put_task, struct task_struct *, if (_T) put_task_struct(_T)) include/linux/slab.h:231:DEFINE_FREE(kfree, void *, if (_T) kfree(_T)) For the patch: Acked-by: Yury Norov <yury.norov@gmail.com>
On Tue, Sep 12, 2023 at 3:43 PM Yury Norov <yury.norov@gmail.com> wrote: > > On Tue, Sep 12, 2023 at 10:55:38AM +0200, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > > > Add support for autopointers for bitmaps allocated with bitmap_alloc() > > et al. > > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > --- > > include/linux/bitmap.h | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > > index 03644237e1ef..ba8c0d733842 100644 > > --- a/include/linux/bitmap.h > > +++ b/include/linux/bitmap.h > > @@ -6,6 +6,7 @@ > > > > #include <linux/align.h> > > #include <linux/bitops.h> > > +#include <linux/cleanup.h> > > #include <linux/find.h> > > #include <linux/limits.h> > > #include <linux/string.h> > > @@ -125,6 +126,8 @@ unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node); > > unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node); > > void bitmap_free(const unsigned long *bitmap); > > > > +DEFINE_FREE(bitmap, unsigned long *, bitmap_free(_T)) > > So now it doesn't do weird "if (_T) bitmap_free(_T)". Have you got any > feedback from Peter for that? > I did get feedback from Peter. Unfortunately it was right *after* I sent this. Turns out the NULL-pointer check is there for a reason, please see the comment in this patch: https://lore.kernel.org/all/169451499208.27769.5856056754166699857.tip-bot2@tip-bot2/T/#u That means I will have to resend this one. Bart > My point is that if the above is correct, all the following > declarations need to be revisited: > > yury:linux$ git grep DEFINE_FREE|grep if > include/linux/cleanup.h:25: * DEFINE_FREE(kfree, void *, if (_T) kfree(_T)) > include/linux/device.h:1058:DEFINE_FREE(device_del, struct device *, if (_T) device_del(_T)) > include/linux/device.h:1228:DEFINE_FREE(put_device, struct device *, if (_T) put_device(_T)) > include/linux/mutex.h:224:DEFINE_FREE(mutex, struct mutex *, if (_T) mutex_unlock(_T)) > include/linux/rwsem.h:208:DEFINE_FREE(up_read, struct rw_semaphore *, if (_T) up_read(_T)) > include/linux/rwsem.h:209:DEFINE_FREE(up_write, struct rw_semaphore *, if (_T) up_write(_T)) > include/linux/sched/task.h:164:DEFINE_FREE(put_task, struct task_struct *, if (_T) put_task_struct(_T)) > include/linux/slab.h:231:DEFINE_FREE(kfree, void *, if (_T) kfree(_T)) > > For the patch: > Acked-by: Yury Norov <yury.norov@gmail.com>
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 03644237e1ef..ba8c0d733842 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -6,6 +6,7 @@ #include <linux/align.h> #include <linux/bitops.h> +#include <linux/cleanup.h> #include <linux/find.h> #include <linux/limits.h> #include <linux/string.h> @@ -125,6 +126,8 @@ unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node); unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node); void bitmap_free(const unsigned long *bitmap); +DEFINE_FREE(bitmap, unsigned long *, bitmap_free(_T)) + /* Managed variants of the above. */ unsigned long *devm_bitmap_alloc(struct device *dev, unsigned int nbits, gfp_t flags);