Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2249819pxu; Fri, 9 Oct 2020 11:37:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5q7H0//ikPQxotyynQclvIe5Q/PnX/8bFadhBC2orzNgPJRXlv9MuhShtEzm6rDG6we44 X-Received: by 2002:a50:ab5b:: with SMTP id t27mr525080edc.281.1602268635507; Fri, 09 Oct 2020 11:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602268635; cv=none; d=google.com; s=arc-20160816; b=CqC5HLor5vS1sycu/Qfb4oyrI7+1MC8uh7QfWkH6XNzCT/YQfgMNXJCSx8XUBPLj2C pWzxk9oDnsrkv/W1jZ0tdkzA5mRukzjqLGN8r18t7oDAlzfYxB0HIUGkY97KGmM+LOHE nphr1dlbfrmxM1+1StqCV3P9/6lrHGVl5KbHkBIePXR4wC934NMY8fy39BfUjDgUvjry RPubWvIwmL83acxavhzHRJPMOJi4Gk6KmN5XUqvuQi133mb49kLJ/6pSVcemxe38rRK5 eqkntFzbeXdJC+PdGTuRmX61xhAWUKotYRZequptKCT67OWplXthrK7/iELwKj2KXVIU ym+g== 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; bh=AJLwlDreOTu9E3bmosdSuLK6PqXZ1aXx/xmTJ/4R+lc=; b=J4VVxvyYPXrZu3yC/SGXwlplWkBQtsalpM524ppiBkOzZpniCBFJuFsIaLpv2r7x74 jP0beti1liRlJ8n9diBSzPnZYTDbWc6LBVC2zyWYr/Kr7VTRcjMEX9/6e89mkkV6f0yQ xtmYpbbU5oNQI4dpOEG+SddYh3kf/75cNSDXND3bnkfGEgF3FnGTIUNBXEiMGPc5twox mIJ8gmbFMLFm5f2TATEO17IT+Va15pcKm0NcjIDhYpc+r1F32QepFk+aw5Do4eHznTDb NSv6D5D4bZFxwMKPd+HEfzxhn7mB5cwVmwICGNvNpYZV6tzs3KUk3ci7UPwgCA3IH0l8 PFAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si6459606eds.287.2020.10.09.11.36.52; Fri, 09 Oct 2020 11:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733144AbgJIMaC (ORCPT + 99 others); Fri, 9 Oct 2020 08:30:02 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:34613 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733111AbgJIMaA (ORCPT ); Fri, 9 Oct 2020 08:30:00 -0400 Received: by mail-ed1-f67.google.com with SMTP id x1so9161246eds.1 for ; Fri, 09 Oct 2020 05:29:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AJLwlDreOTu9E3bmosdSuLK6PqXZ1aXx/xmTJ/4R+lc=; b=STbt1PB7h8+1n22m9awQQ7sGHHLZyXNUn0oxi7/LQpTarUJT2nR3oOaK6cM1c6BRaf w/E4dH8M+3jtn3HjsVctUa5CTlR/XdAdsLKtV9ToRGfTOMSGmq0dalmGLG/dHxicMbTr cIiiplH2b6f+P9N5O7tu1hOg91nJ3WFR/o+4g5PZ2Uucx5YBpYNLRjH3lQyHKIrH1Usi vC8iOSOdGkSdGvFjbRExAjGLgLy1JvDLoOzSPzF5lX7/dJNrjUEIAZ6LXi1vcN9WGefu zrRSSkA+fRZ5pBrAchmeYvT7CwwyilIMPnlxySISBz3kRSrb7DwWdxcL5B0wWbuzUjdZ cv1Q== X-Gm-Message-State: AOAM531caVzraAv7/ZYhTJsYgV9Z0BRgwptrg38Oq5GrtMO4rgekh99E FZQ7wb1CsFT68sotx17ieBs= X-Received: by 2002:aa7:d30d:: with SMTP id p13mr11152960edq.315.1602246596809; Fri, 09 Oct 2020 05:29:56 -0700 (PDT) Received: from tiehlicka.suse.cz (ip-85-160-42-169.eurotel.cz. [85.160.42.169]) by smtp.gmail.com with ESMTPSA id q27sm6412701ejd.74.2020.10.09.05.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2020 05:29:56 -0700 (PDT) From: Michal Hocko To: Peter Zijlstra , Thomas Gleixner Cc: Mel Gorman , Frederic Weisbecker , Ingo Molnar , LKML , Michal Hocko Subject: [RFC PATCH v2 1/5] jump_label: split out declaration parts into its own headers Date: Fri, 9 Oct 2020 14:29:22 +0200 Message-Id: <20201009122926.29962-2-mhocko@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009122926.29962-1-mhocko@kernel.org> References: <20201007120401.11200-1-mhocko@kernel.org> <20201009122926.29962-1-mhocko@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Hocko Follow up patch would like to add a static key into kernel.h and that requires a declaration of the key in the same file. Including jump_label.h into kernel.h is not possible due to headers dependencies. Separate parts needed for declaration into its own header which doesn't depend on any other header file. kernel.h can include jump_abel_type.h. Signed-off-by: Michal Hocko --- include/linux/jump_label.h | 44 +---------------------------- include/linux/jump_label_type.h | 49 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 43 deletions(-) create mode 100644 include/linux/jump_label_type.h diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 32809624d422..bd0d846d0bde 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -75,6 +75,7 @@ #include #include +#include extern bool static_key_initialized; @@ -82,35 +83,6 @@ extern bool static_key_initialized; "%s(): static key '%pS' used before call to jump_label_init()", \ __func__, (key)) -#ifdef CONFIG_JUMP_LABEL - -struct static_key { - atomic_t enabled; -/* - * Note: - * To make anonymous unions work with old compilers, the static - * initialization of them requires brackets. This creates a dependency - * on the order of the struct with the initializers. If any fields - * are added, STATIC_KEY_INIT_TRUE and STATIC_KEY_INIT_FALSE may need - * to be modified. - * - * bit 0 => 1 if key is initially true - * 0 if initially false - * bit 1 => 1 if points to struct static_key_mod - * 0 if points to struct jump_entry - */ - union { - unsigned long type; - struct jump_entry *entries; - struct static_key_mod *next; - }; -}; - -#else -struct static_key { - atomic_t enabled; -}; -#endif /* CONFIG_JUMP_LABEL */ #endif /* __ASSEMBLY__ */ #ifdef CONFIG_JUMP_LABEL @@ -343,14 +315,6 @@ static inline void static_key_disable(struct static_key *key) * All the below code is macros in order to play type games. */ -struct static_key_true { - struct static_key key; -}; - -struct static_key_false { - struct static_key key; -}; - #define STATIC_KEY_TRUE_INIT (struct static_key_true) { .key = STATIC_KEY_INIT_TRUE, } #define STATIC_KEY_FALSE_INIT (struct static_key_false){ .key = STATIC_KEY_INIT_FALSE, } @@ -360,18 +324,12 @@ struct static_key_false { #define DEFINE_STATIC_KEY_TRUE_RO(name) \ struct static_key_true name __ro_after_init = STATIC_KEY_TRUE_INIT -#define DECLARE_STATIC_KEY_TRUE(name) \ - extern struct static_key_true name - #define DEFINE_STATIC_KEY_FALSE(name) \ struct static_key_false name = STATIC_KEY_FALSE_INIT #define DEFINE_STATIC_KEY_FALSE_RO(name) \ struct static_key_false name __ro_after_init = STATIC_KEY_FALSE_INIT -#define DECLARE_STATIC_KEY_FALSE(name) \ - extern struct static_key_false name - #define DEFINE_STATIC_KEY_ARRAY_TRUE(name, count) \ struct static_key_true name[count] = { \ [0 ... (count) - 1] = STATIC_KEY_TRUE_INIT, \ diff --git a/include/linux/jump_label_type.h b/include/linux/jump_label_type.h new file mode 100644 index 000000000000..37cb02c12f35 --- /dev/null +++ b/include/linux/jump_label_type.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_JUMP_LABEL_TYPE_H +#define _LINUX_JUMP_LABEL_TYPE_H + +#ifdef CONFIG_JUMP_LABEL + +struct static_key { + atomic_t enabled; +/* + * Note: + * To make anonymous unions work with old compilers, the static + * initialization of them requires brackets. This creates a dependency + * on the order of the struct with the initializers. If any fields + * are added, STATIC_KEY_INIT_TRUE and STATIC_KEY_INIT_FALSE may need + * to be modified. + * + * bit 0 => 1 if key is initially true + * 0 if initially false + * bit 1 => 1 if points to struct static_key_mod + * 0 if points to struct jump_entry + */ + union { + unsigned long type; + struct jump_entry *entries; + struct static_key_mod *next; + }; +}; + +#else +struct static_key { + atomic_t enabled; +}; +#endif /* CONFIG_JUMP_LABEL */ + +struct static_key_true { + struct static_key key; +}; + +struct static_key_false { + struct static_key key; +}; + +#define DECLARE_STATIC_KEY_TRUE(name) \ + extern struct static_key_true name + +#define DECLARE_STATIC_KEY_FALSE(name) \ + extern struct static_key_false name + +#endif /* _LINUX_JUMP_LABEL_TYPE_H */ -- 2.28.0