From patchwork Wed Jan 31 14:50:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 194806 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1957940dyb; Wed, 31 Jan 2024 07:16:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGV4lp88Vry5EkJoF3irI+rGYYIVGFQE+X9THbsg3bm5+2xFNtFFrNwWemYIHGwmp6cO0aV X-Received: by 2002:a17:906:dfcb:b0:a29:7ddf:40eb with SMTP id jt11-20020a170906dfcb00b00a297ddf40ebmr1391946ejc.15.1706714209692; Wed, 31 Jan 2024 07:16:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706714209; cv=pass; d=google.com; s=arc-20160816; b=eNGlAcq5H58Xg4jPZe8/ZuzTlgtpS7gLURuyoHthU/hekF3LRJVRnH3dE6jaoFHm6k vnieAFds7Ck7yC1KhH6oNxIcq5F/m1WCuusP0zMgYfkeQYYsK/Wn0izIWJF2n/rSw4a2 qB7adGsKXoujXBHuarP2e4iGxUwtzcdya6LtYwcErsAgwKMyDLPTp8sITjreE0lpBoSy CD8KBQ7bX+qGMXZt29RandsszNm+VXn8oHzxSA/hXMcOrRTP9plOrgITFk10qBvhpKUB KuhtJE/fMwTzaFNZhL7CkK6UVuMPzkQTUVwyFqfjIWymF99pegmtGA2wwUibVD6Yq+Ma vMbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=832vfSrkeF3QnV1R+jKUiXGq3To3W4yBcWkWbh9r2EA=; fh=bqTguDRVWJgR6kd7EAYj+9BtSM4YrjfdnW1IIz+UORQ=; b=OwVrZcA6r0RdpHxTFmJzTj2heaTQP84Vsj3PCHu0tagnDqHLchH+4SkqP3soQ3kchi tYdojMzc8seiRovLTPxUqD4lLtHV/nktzOGLm36UaypCEeEz7tSe3lul5gTIfbEBhhxt XGduf9ZXmkJPt/rrd6e1Boy9sFVbEgumNuaxFjCVHJhNt6QMYpSHI1tcspDSJr9pRM/y 6s3LjxG74yZEXl1VNwz6O8m465gPm5i0RtMtrc+bmSdi0bE9gV6nQKZwONM1YNg2oSkk 9Lbe134F9RXKdqyWfTYTmaEGPzyHShJiaCVxzw1IM7x3cG5QoIlee/T+3gZU8lvBLLwJ 7kvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="SU+L/F9r"; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-46654-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46654-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com X-Forwarded-Encrypted: i=1; AJvYcCXi8qtlkSS+lxdaKMYbS+qNgepPR2JSh7JGSjUUv9K2syX2dCPRPkTXG0mYDN6bqDDJRK5pB0rJqTgQmdFhxQIkdNAB3A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a16-20020a17090640d000b00a3178e6cfb0si5575644ejk.705.2024.01.31.07.16.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 07:16:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46654-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="SU+L/F9r"; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-46654-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46654-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 994A71F2CF68 for ; Wed, 31 Jan 2024 14:57:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9863C13D50A; Wed, 31 Jan 2024 14:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="SU+L/F9r" Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 12FED12DD95 for ; Wed, 31 Jan 2024 14:50:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706712642; cv=none; b=mwZRk45CZELErBcumWlpWb8SofxQ7vpnn1oy92nOSXAzSF7VmbAA+YoAP/KKSrGbxHPpjs3eL0WvBe4JSediHyopBiCeDb1wirOLx1s5KayRWY8dkxVhtyuPIIYp4751r2MeI59GhG5nhJQ9ZabrRsR3AIM/v+VvZrq9TxaZgG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706712642; c=relaxed/simple; bh=wFqLf+lTO1P01iuDQ0Av3gwXEV1N5t6nBLfx+ncslxY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JoWZqlPN+hCdAWcSIYL9Er8JtdmwNlsly9wKi6PcLXeVo4UNHVaQh14H79mMptivRXOXXPkZFprstrzqzvgSLALK7xB13BUg0RU+/+k+XmV9ncG6WCUNd7DtbT8K/AHy4oBL/Fpx+kKK89QG/qX3wKQkt7SJeKCFl0A90dAqxgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=SU+L/F9r; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-33b01484cd7so685127f8f.0 for ; Wed, 31 Jan 2024 06:50:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1706712633; x=1707317433; 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=832vfSrkeF3QnV1R+jKUiXGq3To3W4yBcWkWbh9r2EA=; b=SU+L/F9r8knT9XF5i5XNkPMVU2d3zl3P0gCeOEhcQ4wJqVFVVpt3Wwi4ti5oPbhQmk RyPI0EZOt5nhqfgHfsY9yqBHCoAGDnNIYq8OCGh2Yr2IkSiM7SX7tVgqu8K2oavL7FMI z+SCDRONftSPUQ5KtDtQIhNt1xchb3yVzh2eT5jUBgtolTNgJJiZ/uz/OGpFYJHYlY02 VzwjZ8Shn8/e7Ov3x0roJ2nb+LJnNkSqUn5ynQenZ1L1/gupx+ZrsmxZmRo5KQFvC5rB GUVbnDtifuwlaG6J1vOGs+stLH4Kvn6WRYApTyc4SriHg6hY+Lp3IvGAQ2SQbMtRGB9r Ibpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706712633; x=1707317433; 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=832vfSrkeF3QnV1R+jKUiXGq3To3W4yBcWkWbh9r2EA=; b=N3VgNzM/442TmytaKuu/F6iYDNjqiz4PmZuPG5X8/cU/hIHfJx517oi+3ITJQrDwyk f3EtKzlxA9VQxXxnsJJF5DoJpKhLSJ+evAgt1P/hwup1jC9CImkukh6ItAFe+Kezsswj /4tEmC6IvQTgdK0w5tiZ5V3n8w8T/BHzdRIrunQftsWSf2bXBEvQsArbrFWybThrgeJX KfOFUSnZx3W8ToS7DHzFBEW2SAAFjWJzkMfsKjzEMON9Haj97vCMIA3bIDlM9uNqmLSW 4GpMIz4ywSo2y5IcUkDakDOqk/+JA5N9b2B8DLZvxBx4+MZ8HIOlc6PcrzEmy5UP9yls Oyqg== X-Gm-Message-State: AOJu0YyYop++IepLN0TKAHx3K2fZz3g/KJxGe1essa+6qYAOijv1hBCR goQ+EPa9yRz3RkXQU8W37iaVUft0as9Cgtt4RmP2UvgLqMpIj7SbE9y/QlqNkNg5z3wycGOFDmB n X-Received: by 2002:a5d:4448:0:b0:33a:e6cf:f564 with SMTP id x8-20020a5d4448000000b0033ae6cff564mr1220964wrr.28.1706712633473; Wed, 31 Jan 2024 06:50:33 -0800 (PST) Received: from raven.blarg.de (p200300dc6f2f5c00023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f2f:5c00:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id ch15-20020a5d5d0f000000b0033905a60689sm13850173wrb.45.2024.01.31.06.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 06:50:32 -0800 (PST) From: Max Kellermann To: linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH 21/28] percpu-refcount.h: move declarations to percpu-refcount_types.h Date: Wed, 31 Jan 2024 15:50:01 +0100 Message-Id: <20240131145008.1345531-22-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131145008.1345531-1-max.kellermann@ionos.com> References: <20240131145008.1345531-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789619559200327838 X-GMAIL-MSGID: 1789619559200327838 By providing declarations in a lean header, we can reduce header dependencies. Signed-off-by: Max Kellermann --- drivers/target/target_core_alua.c | 1 + drivers/target/target_core_pr.c | 1 + drivers/target/target_core_xcopy.c | 1 + include/linux/blkdev.h | 2 +- include/linux/bpf-cgroup-defs.h | 2 +- include/linux/bpf.h | 2 +- include/linux/cgroup-defs.h | 2 +- include/linux/cgroup.h | 1 + include/linux/percpu-refcount.h | 64 +----------------------- include/linux/percpu-refcount_types.h | 71 +++++++++++++++++++++++++++ include/linux/slab.h | 1 - include/target/target_core_base.h | 2 +- 12 files changed, 81 insertions(+), 69 deletions(-) create mode 100644 include/linux/percpu-refcount_types.h diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 01751faad386..f908e5562094 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index a566d4d38192..19057040b7a1 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c index c822f57daa39..232d84743b89 100644 --- a/drivers/target/target_core_xcopy.c +++ b/drivers/target/target_core_xcopy.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 09e8f023070c..bc108e5fcec0 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include // for iov_iter_is_aligned() diff --git a/include/linux/bpf-cgroup-defs.h b/include/linux/bpf-cgroup-defs.h index f3b400858129..70b79fd81fee 100644 --- a/include/linux/bpf-cgroup-defs.h +++ b/include/linux/bpf-cgroup-defs.h @@ -5,7 +5,7 @@ #ifdef CONFIG_CGROUP_BPF #include -#include +#include #include struct bpf_prog_array; diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 40fce6ce3de9..b6e38331acfd 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 99e24f3034df..878deefba0e1 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 24dcff53bd05..19a5e801f77d 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index dd2f19ea08bd..ded13def0acd 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h @@ -50,74 +50,12 @@ #ifndef _LINUX_PERCPU_REFCOUNT_H #define _LINUX_PERCPU_REFCOUNT_H -#include +#include #include #include #include #include -struct percpu_ref; -typedef void (percpu_ref_func_t)(struct percpu_ref *); - -/* flags set in the lower bits of percpu_ref->percpu_count_ptr */ -enum { - __PERCPU_REF_ATOMIC = 1LU << 0, /* operating in atomic mode */ - __PERCPU_REF_DEAD = 1LU << 1, /* (being) killed */ - __PERCPU_REF_ATOMIC_DEAD = __PERCPU_REF_ATOMIC | __PERCPU_REF_DEAD, - - __PERCPU_REF_FLAG_BITS = 2, -}; - -/* @flags for percpu_ref_init() */ -enum { - /* - * Start w/ ref == 1 in atomic mode. Can be switched to percpu - * operation using percpu_ref_switch_to_percpu(). If initialized - * with this flag, the ref will stay in atomic mode until - * percpu_ref_switch_to_percpu() is invoked on it. - * Implies ALLOW_REINIT. - */ - PERCPU_REF_INIT_ATOMIC = 1 << 0, - - /* - * Start dead w/ ref == 0 in atomic mode. Must be revived with - * percpu_ref_reinit() before used. Implies INIT_ATOMIC and - * ALLOW_REINIT. - */ - PERCPU_REF_INIT_DEAD = 1 << 1, - - /* - * Allow switching from atomic mode to percpu mode. - */ - PERCPU_REF_ALLOW_REINIT = 1 << 2, -}; - -struct percpu_ref_data { - atomic_long_t count; - percpu_ref_func_t *release; - percpu_ref_func_t *confirm_switch; - bool force_atomic:1; - bool allow_reinit:1; - struct rcu_head rcu; - struct percpu_ref *ref; -}; - -struct percpu_ref { - /* - * The low bit of the pointer indicates whether the ref is in percpu - * mode; if set, then get/put will manipulate the atomic_t. - */ - unsigned long percpu_count_ptr; - - /* - * 'percpu_ref' is often embedded into user structure, and only - * 'percpu_count_ptr' is required in fast path, move other fields - * into 'percpu_ref_data', so we can reduce memory footprint in - * fast path. - */ - struct percpu_ref_data *data; -}; - int __must_check percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release, unsigned int flags, gfp_t gfp); diff --git a/include/linux/percpu-refcount_types.h b/include/linux/percpu-refcount_types.h new file mode 100644 index 000000000000..9f4f93e8faaf --- /dev/null +++ b/include/linux/percpu-refcount_types.h @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_PERCPU_REFCOUNT_TYPES_H +#define _LINUX_PERCPU_REFCOUNT_TYPES_H + +#include +#include + +struct percpu_ref; +typedef void (percpu_ref_func_t)(struct percpu_ref *); + +/* flags set in the lower bits of percpu_ref->percpu_count_ptr */ +enum { + __PERCPU_REF_ATOMIC = 1LU << 0, /* operating in atomic mode */ + __PERCPU_REF_DEAD = 1LU << 1, /* (being) killed */ + __PERCPU_REF_ATOMIC_DEAD = __PERCPU_REF_ATOMIC | __PERCPU_REF_DEAD, + + __PERCPU_REF_FLAG_BITS = 2, +}; + +/* @flags for percpu_ref_init() */ +enum { + /* + * Start w/ ref == 1 in atomic mode. Can be switched to percpu + * operation using percpu_ref_switch_to_percpu(). If initialized + * with this flag, the ref will stay in atomic mode until + * percpu_ref_switch_to_percpu() is invoked on it. + * Implies ALLOW_REINIT. + */ + PERCPU_REF_INIT_ATOMIC = 1 << 0, + + /* + * Start dead w/ ref == 0 in atomic mode. Must be revived with + * percpu_ref_reinit() before used. Implies INIT_ATOMIC and + * ALLOW_REINIT. + */ + PERCPU_REF_INIT_DEAD = 1 << 1, + + /* + * Allow switching from atomic mode to percpu mode. + */ + PERCPU_REF_ALLOW_REINIT = 1 << 2, +}; + +struct percpu_ref_data { + atomic_long_t count; + percpu_ref_func_t *release; + percpu_ref_func_t *confirm_switch; + bool force_atomic:1; + bool allow_reinit:1; + struct rcu_head rcu; + struct percpu_ref *ref; +}; + +struct percpu_ref { + /* + * The low bit of the pointer indicates whether the ref is in percpu + * mode; if set, then get/put will manipulate the atomic_t. + */ + unsigned long percpu_count_ptr; + + /* + * 'percpu_ref' is often embedded into user structure, and only + * 'percpu_count_ptr' is required in fast path, move other fields + * into 'percpu_ref_data', so we can reduce memory footprint in + * fast path. + */ + struct percpu_ref_data *data; +}; + +#endif diff --git a/include/linux/slab.h b/include/linux/slab.h index 63c8b1ce6133..95439c2e7542 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 5b9156adceca..1598a4062398 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -5,7 +5,7 @@ #include /* struct config_group */ #include /* enum dma_data_direction */ #include -#include +#include #include /* struct semaphore */ #include