From patchwork Mon Feb 12 11:54:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 199711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2387945dyd; Mon, 12 Feb 2024 04:16:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU85kwGIVxoKg4QtPFgnhCNxnCItVLGW+xEKIgpd3qk+OHDKNoL5ZdH5YixfSbCophQ8Lvo/WP8nnYHN//9vzaUx/AqpA== X-Google-Smtp-Source: AGHT+IEhlp4Lzx5lC194AkXI01sBzq1Dt6ZAHQXkYzi7IJx1+JckMKBX2yQCIfdNNqCClRLH4fcq X-Received: by 2002:a05:6a21:9206:b0:19e:9c32:6073 with SMTP id tl6-20020a056a21920600b0019e9c326073mr5102609pzb.12.1707740199330; Mon, 12 Feb 2024 04:16:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707740199; cv=pass; d=google.com; s=arc-20160816; b=O4+7MB6MXgfu3L4r7KZSIJSnSw6LRYyEHL3ArFFKE2PKtTTUsjJobXIbyfWw6ud1Lt qGmdyIiwDPt6ptN9kjY7KAcdZQocaJ8DkPn4Jo5NXPLDteCUKD5GFNfLkS8AFEvprsWs uRSszwA3kwvwgk84Y15VLDl7imnAbjIUokwJD1goqnDimRlNCubJqNE1ypUOHzvk8+ld TaFZjM0MbJhYHcEA17nkqISCLPkT7qMLa30+u+GSb0k5c6EVhFWioeYcanmqB7z9XO1d FQQWgHuc5yYw4oqarGAi2OYo3f2ATvvfH516J0b1YmvygZJ+WsRDNN+KVGJ4s7Oxaulh VrpQ== 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=eDQVvsZa2nL9HSHS1Gx/1/AJzgcPIcre4NclndEUteM=; fh=XO30QBbhGaLKuZbpDdx6l1ecQYDDtu7t02X4XHJRHAw=; b=eF1qEO/7O+Iqbt571OGbIqFjNXkVvPvUKBVlSeEH/GF+y6lzRQXcnuk5tfy4un7wF+ KTSNL+MfhX97vOKt00OB+DU7r/RDR3eaJLDG7/U8nDxPswmXN2iTdb6fAY/7eubuDFrj EICCw2KwlrfCesg5OGxOfDl3m3Y/35yuHaypsugr0jjka+rO3vhyscFIQFAwL2Z2gYBs K0HcFl+ny+/qeahPmRXRZmXM4p+tnULs9JBiL5/BXdbABSEo/M1ackHj3A3xwV5yJP86 iQ5ZUIokr2Q49Cl68gIsLcizThnHl4ZmLL2xz1aRCnvZ1SfT3utiJb/ceOZBNZF+3nXG iSSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=QmkiQDdx; 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-61469-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61469-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com X-Forwarded-Encrypted: i=2; AJvYcCWTZE4XBqt4ND+GPDupJw7Fzn0yCjqdvryBilykT7qec9pOuiWIvAZyiuFmUa53xpx9KRieil39o3n/ixfsKtYl6ke+iQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p19-20020a637f53000000b005dc4912432csi157589pgn.577.2024.02.12.04.16.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:16:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61469-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=QmkiQDdx; 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-61469-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61469-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 72A81B268B7 for ; Mon, 12 Feb 2024 11:57:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3A1139AE1; Mon, 12 Feb 2024 11:55:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="QmkiQDdx" Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.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 DBD2939AFD for ; Mon, 12 Feb 2024 11:55:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707738927; cv=none; b=GJPdT9V99q03LfACeSKD9Eq8dSZ50OiiEp96yh+sJFKmStQWaeyisDFkPTGDllWEpCM18/ooeueS832txyzkMZnbgzaTPq3j7dB7G3M9XdMHrB8IZpiOT+qKp+eCWL1Vy9373CaiAbftR5fWHYACse37epbiAZvKpAuhWasnwW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707738927; c=relaxed/simple; bh=Wgxe8LKbu4ZHhN8cRCWW0ZEkIjgOVquJJfcSHXqlYXs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KRR7+NnHMmGMPZCkL261Yi1SFedYClPlM6zlPkKbOO9RIJ717nM8MpN8GVvVKVUlRmROYIoRmQsigCPOZvcw83AyK8pX73sd2LjlhqnDW5yxjpZT3lFMuXSGcRDgPB9zAlvnps5P6BNVa1vejEXfeHvQO4ExwpFJ2YwM3PuHsGQ= 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=QmkiQDdx; arc=none smtp.client-ip=209.85.208.179 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-lj1-f179.google.com with SMTP id 38308e7fff4ca-2d073b54359so47093161fa.0 for ; Mon, 12 Feb 2024 03:55:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1707738921; x=1708343721; 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=eDQVvsZa2nL9HSHS1Gx/1/AJzgcPIcre4NclndEUteM=; b=QmkiQDdx3y/E9FiBCdpO/9uZiW/lmgjrDpw2iXzJutQv/zvoDKb4qqzAPRnBcHpU+T avFrKiG0G0ZOVa2EIf7k+sm/rEX8gBOEgsboPv3+/oT30ZNXutifW1Ky1v4NdN9A6p36 k/0KPDGMCAiq5eg/rzraXc/EJdPP2Pabt0iFE6KNC0F4gS/+qtTc52GcAAOqd9loylQ6 a0yslbJnNk4QIxPFuOU751OTjfMbFPLMctvCasQDsCIVIsbscHSxfhtY5MNg4F1VsmOP ccQ6ax6VEHnwoSEx9B5W9Sb+XJ5LWvHojKbmurKZkjp6xRA+sUOKGiEroEt5G21Osilt Y4Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707738921; x=1708343721; 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=eDQVvsZa2nL9HSHS1Gx/1/AJzgcPIcre4NclndEUteM=; b=k1skejv804SL7R1yR3fQHc+rLAwXPJPSN0l6l44YI7i8KPGF84nTi2dXc94B1q33bD SjfV1dJZ16aAFOQ6La8Jhh8DWpp0jRRx+sAt6ZjcIkHkwil/VzQIPB0VhF6gVfHtitcT f4CRhy6Xfzm6ZYjzbvpAyjyAx/iRbfHRn2Tvl415KDWUss5d3l0fhJSsp2f4JskdiIqN NB48XsP5aV2bpUJK1izcjjF62F4U3/AGe8AAokW7xhALzxzqxDNPMgWvQIC4Dm7GYCIN HxMa4TJudwDPrLVzXmVn5Bycu7ynxdNdpvdDu/fWVY9zJXIKzOTY238RSd+lwWs71EW9 MQmg== X-Gm-Message-State: AOJu0YxTziSFcQ324kNiGKd7zfVYh/gGPPP4tIS8B6JGOwsfamsUDJM/ H4sol4nStNreNohnNbODQ0rhmYYIRTW7KyAvxDFMGo2QGIqJI995G9yMPSlGfqJVsSWaAKGFpNz 3 X-Received: by 2002:a2e:b0e6:0:b0:2d0:e35a:3bab with SMTP id h6-20020a2eb0e6000000b002d0e35a3babmr3919119ljl.48.1707738921595; Mon, 12 Feb 2024 03:55:21 -0800 (PST) Received: from raven.blarg.de (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id m1-20020a17090607c100b00a36c3e2e52dsm139203ejc.61.2024.02.12.03.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 03:55:19 -0800 (PST) From: Max Kellermann To: linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v5 09/35] rwsem.h: move declarations to rwsem_types.h Date: Mon, 12 Feb 2024 12:54:34 +0100 Message-Id: <20240212115500.2078463-10-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212115500.2078463-1-max.kellermann@ionos.com> References: <20240212115500.2078463-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: 1790695386885261599 X-GMAIL-MSGID: 1790695386885261599 By providing declarations in a lean header, we can reduce header dependencies. Signed-off-by: Max Kellermann --- include/linux/backing-dev-defs.h | 2 +- include/linux/comedi/comedidev.h | 2 +- include/linux/gnss.h | 2 +- include/linux/i3c/master.h | 2 +- include/linux/ipc_namespace.h | 2 +- include/linux/leds.h | 2 +- include/linux/mfd/intel-m10-bmc.h | 2 +- include/linux/mm_types.h | 2 +- include/linux/nfs_fs.h | 2 +- include/linux/posix-clock.h | 2 +- include/linux/quota.h | 2 +- include/linux/rwsem.h | 48 +------------------ include/linux/rwsem_types.h | 78 +++++++++++++++++++++++++++++++ include/linux/tty.h | 2 +- include/linux/user_namespace.h | 2 +- include/net/sch_generic.h | 2 +- include/rdma/ib_verbs.h | 2 +- include/sound/core.h | 2 +- 18 files changed, 95 insertions(+), 63 deletions(-) create mode 100644 include/linux/rwsem_types.h diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h index 2e041aedc317..ce5bda191ec5 100644 --- a/include/linux/backing-dev-defs.h +++ b/include/linux/backing-dev-defs.h @@ -15,7 +15,7 @@ #include #ifdef CONFIG_CGROUP_WRITEBACK -#include +#include #endif struct page; diff --git a/include/linux/comedi/comedidev.h b/include/linux/comedi/comedidev.h index d7a75b15c6f7..a3c2268f7ae5 100644 --- a/include/linux/comedi/comedidev.h +++ b/include/linux/comedi/comedidev.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/linux/gnss.h b/include/linux/gnss.h index 8fc4bdd38dc6..9f38ff948d78 100644 --- a/include/linux/gnss.h +++ b/include/linux/gnss.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 16cc81e55b12..0e456edeebbf 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #define I3C_HOT_JOIN_ADDR 0x2 diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index e8240cf2611a..a0011b6cd5d1 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/linux/leds.h b/include/linux/leds.h index bec1c2fa5b26..6a50c2ea10e2 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/linux/mfd/intel-m10-bmc.h b/include/linux/mfd/intel-m10-bmc.h index ee66c9751003..3500f5fa8057 100644 --- a/include/linux/mfd/intel-m10-bmc.h +++ b/include/linux/mfd/intel-m10-bmc.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #define M10BMC_N3000_LEGACY_BUILD_VER 0x300468 #define M10BMC_N3000_SYS_BASE 0x300800 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index ff5d33ace0f9..ed764511bc23 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 4511d8a50e15..8f14fce5d7e2 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h index ef8619f48920..f8e0c65d262d 100644 --- a/include/linux/posix-clock.h +++ b/include/linux/posix-clock.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include struct posix_clock; struct posix_clock_context; diff --git a/include/linux/quota.h b/include/linux/quota.h index bf16d9d2866c..956281c84850 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index 9c29689ff505..ba9532734bf6 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -8,10 +8,10 @@ #ifndef _LINUX_RWSEM_H #define _LINUX_RWSEM_H +#include #include #include -#include #include #include #include @@ -29,43 +29,6 @@ #ifndef CONFIG_PREEMPT_RT -#ifdef CONFIG_RWSEM_SPIN_ON_OWNER -#include -#endif - -/* - * For an uncontended rwsem, count and owner are the only fields a task - * needs to touch when acquiring the rwsem. So they are put next to each - * other to increase the chance that they will share the same cacheline. - * - * In a contended rwsem, the owner is likely the most frequently accessed - * field in the structure as the optimistic waiter that holds the osq lock - * will spin on owner. For an embedded rwsem, other hot fields in the - * containing structure should be moved further away from the rwsem to - * reduce the chance that they will share the same cacheline causing - * cacheline bouncing problem. - */ -struct rw_semaphore { - atomic_long_t count; - /* - * Write owner or one of the read owners as well flags regarding - * the current state of the rwsem. Can be used as a speculative - * check to see if the write owner is running on the cpu. - */ - atomic_long_t owner; -#ifdef CONFIG_RWSEM_SPIN_ON_OWNER - struct optimistic_spin_queue osq; /* spinner MCS lock */ -#endif - raw_spinlock_t wait_lock; - struct list_head wait_list; -#ifdef CONFIG_DEBUG_RWSEMS - void *magic; -#endif -#ifdef CONFIG_DEBUG_LOCK_ALLOC - struct lockdep_map dep_map; -#endif -}; - /* In all implementations count != 0 means locked */ static inline int rwsem_is_locked(struct rw_semaphore *sem) { @@ -124,15 +87,6 @@ static inline int rwsem_is_contended(struct rw_semaphore *sem) #else /* !CONFIG_PREEMPT_RT */ -#include - -struct rw_semaphore { - struct rwbase_rt rwbase; -#ifdef CONFIG_DEBUG_LOCK_ALLOC - struct lockdep_map dep_map; -#endif -}; - #define __RWSEM_INITIALIZER(name) \ { \ .rwbase = __RWBASE_INITIALIZER(name), \ diff --git a/include/linux/rwsem_types.h b/include/linux/rwsem_types.h new file mode 100644 index 000000000000..105142147b9b --- /dev/null +++ b/include/linux/rwsem_types.h @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* rwsem.h: R/W semaphores, public interface + * + * Written by David Howells (dhowells@redhat.com). + * Derived from asm-i386/semaphore.h + */ + +#ifndef _LINUX_RWSEM_TYPES_H +#define _LINUX_RWSEM_TYPES_H + +#include +#include +#include + +#ifdef CONFIG_DEBUG_LOCK_ALLOC +#include +# define __RWSEM_DEP_MAP_INIT(lockname) \ + .dep_map = { \ + .name = #lockname, \ + .wait_type_inner = LD_WAIT_SLEEP, \ + }, +#else +# define __RWSEM_DEP_MAP_INIT(lockname) +#endif + +#ifndef CONFIG_PREEMPT_RT + +#ifdef CONFIG_RWSEM_SPIN_ON_OWNER +#include +#endif + +/* + * For an uncontended rwsem, count and owner are the only fields a task + * needs to touch when acquiring the rwsem. So they are put next to each + * other to increase the chance that they will share the same cacheline. + * + * In a contended rwsem, the owner is likely the most frequently accessed + * field in the structure as the optimistic waiter that holds the osq lock + * will spin on owner. For an embedded rwsem, other hot fields in the + * containing structure should be moved further away from the rwsem to + * reduce the chance that they will share the same cacheline causing + * cacheline bouncing problem. + */ +struct rw_semaphore { + atomic_long_t count; + /* + * Write owner or one of the read owners as well flags regarding + * the current state of the rwsem. Can be used as a speculative + * check to see if the write owner is running on the cpu. + */ + atomic_long_t owner; +#ifdef CONFIG_RWSEM_SPIN_ON_OWNER + struct optimistic_spin_queue osq; /* spinner MCS lock */ +#endif + raw_spinlock_t wait_lock; + struct list_head wait_list; +#ifdef CONFIG_DEBUG_RWSEMS + void *magic; +#endif +#ifdef CONFIG_DEBUG_LOCK_ALLOC + struct lockdep_map dep_map; +#endif +}; + +#else /* !CONFIG_PREEMPT_RT */ + +#include + +struct rw_semaphore { + struct rwbase_rt rwbase; +#ifdef CONFIG_DEBUG_LOCK_ALLOC + struct lockdep_map dep_map; +#endif +}; + +#endif /* CONFIG_PREEMPT_RT */ + +#endif /* _LINUX_RWSEM_TYPES_H */ diff --git a/include/linux/tty.h b/include/linux/tty.h index 5a3815e7d73d..da820609bc77 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index 7d0e3418d497..c82e1b50dfcb 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index bab44a435a62..6ec5064156d9 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 64b62d1388a4..7d6216e85b0e 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/sound/core.h b/include/sound/core.h index 0c512acac050..f95f6863986f 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -10,7 +10,7 @@ #include #include /* wake_up() */ #include /* struct mutex */ -#include /* struct rw_semaphore */ +#include /* struct rw_semaphore */ #include #include #include