From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751360AbdFDMCf (ORCPT ); Sun, 4 Jun 2017 08:02:35 -0400 Received: from mail-sn1nam02on0058.outbound.protection.outlook.com ([104.47.36.58]:59812 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751284AbdFDMCO (ORCPT ); Sun, 4 Jun 2017 08:02:14 -0400 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann Cc: Yury Norov , Andrew Pinski , Andrew Pinski , Adam Borowski , Chris Metcalf , Steve Ellcey , Maxim Kuvyrkov , Ramana Radhakrishnan , Florian Weimer , Bamvor Zhangjian , Andreas Schwab , Chris Metcalf , Heiko Carstens , schwidefsky@de.ibm.com, broonie@kernel.org, Joseph Myers , christoph.muellner@theobroma-systems.com, szabolcs.nagy@arm.com, klimov.linux@gmail.com, Nathan_Lynch@mentor.com, agraf@suse.de, Prasun.Kapoor@caviumnetworks.com, geert@linux-m68k.org, philipp.tomsich@theobroma-systems.com, manuel.montezelo@gmail.com, linyongting@huawei.com, davem@davemloft.net, zhouchengming1@huawei.com Subject: [PATCH 08/20] thread: move thread bits accessors to separated file Date: Sun, 4 Jun 2017 14:59:57 +0300 Message-Id: <20170604120009.342-9-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170604120009.342-1-ynorov@caviumnetworks.com> References: <20170604120009.342-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [176.59.55.28] X-ClientProxiedBy: HE1PR09CA0074.eurprd09.prod.outlook.com (10.174.50.146) To BN3PR0701MB1267.namprd07.prod.outlook.com (10.160.118.141) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PR0701MB1267: X-MS-Office365-Filtering-Correlation-Id: 318525a0-31bf-4a1a-236e-08d4ab418259 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BN3PR0701MB1267; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1267;3:tK1fZf/sIOFnP85gOiyf/q/hGd3uwpDG9k559x8ba44FbYDrpKLv2XSq0kFkXzbMYT6ETUGJ6waVtVJS9MlrlcT+Fw1Fgs9T04JZlMXEIMBRrViKe9qZDI7/cIq291DVG4K+14MnlnJJC96AtkYbbSqgVpEYNdQVusB8eCscwDNyDSSi6QoDwJ2YUu/W0TJXVHXIH4zR6W+x8fz1+0kjwwl5iT56bHUd5UPCE5RruGRc6TySYj3Hu9CZyCotl0jCFF+10hW9mV1foF9fLnJHSUNV7fOPCUj4e1vxIu/52J3sDYS8db6oVpVAkbbjGGEsenIpwraiBC7f5hGQPyE6eg==;25:W3LLagwAoMFUPGI4LGz4zeFcmOgZvAmVN7w3dNVccv5gaugfu0+FLd/bLyT4/LZY4HTLqaY2iAtbGu6rwlBZ0WxW2T/tED43U2433AhqJhcxaSdvJrHJ070GMLOerCJSni6+GW2JwRplhdcMOjS3X2BGxz1U47sW7kg5MqRxBDF3g6S/9TQok9B59cdXcS3c+NQBYA5PGkRXdZmQbgrTERNOWN5nJGKvwsoeEShqo9zO0e/REsWmRmivHYPxxFKZp5wLd18eYZhqOmvnljQjW9+Mq3YmBqB+Mfw7wVf+HisStmPT6LRQeYiTB/UoYuDo75zFyqSK3ouOONJ563NNsoipKpevbgaYXiIZrLwLsa7+5sTABtZtB2m5miNdLwOnHt13633V+gn1xEUv4nIpFg8w3JRtoJHar1YNkB5FvePTbCpdZwiltP5t7WY9fVeCgNLTPzVrjT5+Sr0U6R/mDkfEZ/lePBdNWhT8dsT4q/M= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1267;31:m7TCy59qDbq/xAZFyP2VKyowoOit2UahV26D+ZUO9bXrWtHTeHKm1amjB/uMWGNwmr3GnWEjcYt+RV47fAx8ednn+cnlNob6pQdZGBfPMNSlJ5JmILErIXAYv/RQeUR4DrOUcWdLOe4ZbuEaURuT/K/5qbhciXyqSH/AGoJNkM6BGZZlXFhjQgUNW/I6cid9mly/OTtxArYmxJXata5EJVqcHaF8+C+q7Po7aQ2vN6A=;20:BlSUFvPSNf4sUepOikVrQpgeurM+39QagfF3je9tKkZdrsZoKfacp5iG5JPTk/KaHBwDHWdJ/P2Y8ql8W0ZDY7T5PA1keMt9Nm2VU4I/Df2zC+LxSKvOYpxlNLQydODilrDhtdtOzeJup0i0h0/EKi5Ia6GYgYn32Gy0ItJ8bV1tW/DbJb+uthFlq1rakGYLcKAPzKq8dGC5u+F2etwkBHyqoxHCZhIUSECEQQrH75rS/1Hcisa5nN/Vg/0nsp/cenPCypHRKH3LcD5ofwEeb/3lBrru+2Pgz293hUQIsRsoTJhBNJo0/LRl6eUjdeefXuBVKHEtqAhHR0ijy599DpnThx4T+Dra4wJKfvIksfjHG56NetJro29MFaDuxNdlIg07aTKC4CkKBaC7oxz3Z21Dui+aAxaAPPHVXnM/nR+0a6fGyEwHE5EyZhTMDeahrgfoFVBia2eFOXsLx3MS1h57Yu4RIzopgKQNPOX7e+9FVkpEoOvvHO22xivRirXqmujpOr6MavOxHmFDtgvRcCf/LfCzJR74t61+03SFy6WVJwAcq+N7FHB1+dA5zv8RtuIVVINxiyFEbOufr1WQGzKQ8A7tGjc5H7aR0tkXbdQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(10201501046)(3002001)(6041248)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN3PR0701MB1267;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN3PR0701MB1267; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0701MB1267;4:8U8HIhum97lgsNTdYVFD78a3sD9dhPEwL7hr+OCu?= =?us-ascii?Q?g+rqri7FuQwEW6uMHdqqCi3f8C4kbR9TidV945KaPfdfiibm9jTko0ZH0I+3?= =?us-ascii?Q?5n710/ZUXlVFVM8inlX1LAG9TqKxxSHwgR2LrrNBIFSEL2MyejZN852DbBXN?= =?us-ascii?Q?lOKmlpHOTFYOh0bCMFMwF2gI+cem3+aG5X5kWK5z/fZJe8bESQSd1p3LRIZD?= =?us-ascii?Q?y1hDA87LCkP9Ps78y+XBh4Z1xFd0OC5/b46ALIVBZ+goTOdFu7lvmxrzjcLv?= =?us-ascii?Q?6IQfDbXJRvjU6fhv8IYurH1UjfH7VffPPrfKiWoBasM7+Xg5nEGLmR7pinY6?= =?us-ascii?Q?N/LxBk5EHl/vY4l+Cm3OaowpDrNc7VQy6Oj5qu5CK0MZ9mZF7xjoJ4Drx2Q7?= =?us-ascii?Q?/RUz107952I/L6dnRNbJ/z1pANBFciPJ49ZeJQqQD1Q7yFwVQCRIfJAVLJKZ?= =?us-ascii?Q?Xpvy2aSLzl9HCcRbLDdTbZmeW3nZ7vHhNFTD92PHVgex3+qoCakTdAUQ8G13?= =?us-ascii?Q?fvdWJZzOOtMKX2ilxdgaaqhLmpa0LtgeNfyNr3CAdiPYmlAnplZKpLovSQVb?= =?us-ascii?Q?3e3lqeXxY+lYvlPrZo0g0sZUNa7wh6Eey26QT7+72SuQLHWtEd/oAxUclKJ0?= =?us-ascii?Q?txWuMbMsPq5ogD7H7xdjQ/XFlJj1+3ccSaViKHo7tq/2UGVBS0zVEkS+flya?= =?us-ascii?Q?KaqlpJ3FYrfqFhDMIT1yw7IzraYDOBuxZIWWhoHxIeiAs2MPnlavDq5zj6dj?= =?us-ascii?Q?ngR1tf7g8mB5ll9tmbbz85rc3FCH43YKJSHf2pxvIS3FLbRb9ufH9cfyKihk?= =?us-ascii?Q?OGWaoicseS1DHVT5BkCkv8ucmZmS8ScGug10YDCS/AoPucqD5LGaM7fGa5sM?= =?us-ascii?Q?MTRGTBUeB03kAKOqN8X8MsSo08T7xxyAS2f80d1RytZBPtcN5au2cXTunzH7?= =?us-ascii?Q?kj3Y8C7/AIwQ9smHYcGT8hAzw5U6eE5sFB2+DBkSt9MiiM+KivGGtHmVrjuw?= =?us-ascii?Q?H294lSkg5xKCcXP8PxggLhZdPIo0X3gGSIxX7pT4a2n06xOPdCRwletQKKP1?= =?us-ascii?Q?sTBcoQKM4Qnv6ryrn3utGtzOlM1/YU4sYmioffogIe41oi+TFH6Lru0Ljque?= =?us-ascii?Q?2omH0+W13Os=3D?= X-Forefront-PRVS: 03283976A6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(39400400002)(39850400002)(39410400002)(2906002)(72206003)(6666003)(189998001)(2950100002)(42882006)(5003940100001)(478600001)(66066001)(6486002)(53936002)(54906002)(50986999)(76176999)(47776003)(38730400002)(6496005)(48376002)(50466002)(5660300001)(7416002)(76506005)(8676002)(81166006)(36756003)(305945005)(42186005)(33646002)(4326008)(50226002)(25786009)(1076002)(6116002)(3846002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0701MB1267;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0701MB1267;23:eOKN+L3Da5KeyBQw8cuzpoTtsXlcEhIy+PHjRTL?= =?us-ascii?Q?3PLUWKXo6HDR5MnABkWsspx2/riitrdCoILtm+T48TjItRKRYm25wo+9w2F4?= =?us-ascii?Q?EBFe4QOKp29Vfn0eWo/45BlWGFTuNdLxXy43VL7awyiwn4i0f4gKxIDOeOKT?= =?us-ascii?Q?9CRFxVBh4jLkwe2z1IVLf9ZYmOArd5y1Sh2CYRXOHTuVEBg9yeuqRUaQfeJO?= =?us-ascii?Q?oIP+8/STnkchoYJrril8WLUmdqz42Opc50of9pi4og2sBHPeDbLiiAdNxepE?= =?us-ascii?Q?n9S+g/XdtF8JQZe2ThXCwLOP+KduQPeukEwAf5JXgwq5lIVEvz71M2TUTutR?= =?us-ascii?Q?qNV5UoUeVgA0A9UMEJAOr0BGWO011+NSU1X3dI3saftxWzXjvifisBO7H1Mo?= =?us-ascii?Q?7nkDSxj+UguV3ZgQEjRdv/Zzl5ySX+vhMSHs0vfQ7E3XaDAdlZeIFTtQZ9Ta?= =?us-ascii?Q?k7hBUgc2bDe4sC7MW4sPQ2+h+9vgevc5BzsLzREx80rgup9mS6istX/eTYXA?= =?us-ascii?Q?Lry3CU1KZmcM+Z5pwZ8qmztXbnDz+4MKI/vTgTwZbr3AQ+E86SN11IEWICzT?= =?us-ascii?Q?fIlMoehscXHSaK0VKk+dB2OTbdSCfhoThr6migQzu8eKCZ+2Tnv06DrZq8Xv?= =?us-ascii?Q?+Xf8JxMKE0vR9ZP2zR/nTmmAoC1w6xQVtmbt0xraa6qFZVcBDS3h3tnHsA49?= =?us-ascii?Q?TawqZJVKMoF67UAjN2YdvPs7xaqHnPdkhlcjH2RgQnBeCaUfYysWAHJYVpkO?= =?us-ascii?Q?wid1zFqji56lc58BmeXLUI7nvwvR46zaFmqNNGpYAjybphGT855wqKX7c3pm?= =?us-ascii?Q?AIbT8NBF6kh+o0dyyxYVsTAkChv8+2D/5bCMwlH435/thc3Mzecrkkn/kxDO?= =?us-ascii?Q?NLsWBHGeGm2thj/mjVIhTaTQsOmcjama5ms2VrlCPfakgYH1ZZinNlOEYaQF?= =?us-ascii?Q?WGP5DfZghl+yLXirWFe3Voaj9wQy3LMdpPeVUaw6NKnnHaFHoC5iigjRJkW5?= =?us-ascii?Q?CdIHN1unBQ9A1MYorK8gn8YgY?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1267;6:AkkluWQo3iPKbdnVjcKjp/loSH43BPDd1i5qv6BI4fybTBHAnhsVtQczb2EgDL2BTB9MT3h06izjxPGen+LCJxSweGYB7X0gS1w2X3uY5sb1GdEHTyS41pwcOVOxuBT120g+1pXtlH6ktJgmhBg+g3l1UCnCnSTT2aJgZdTNQYW2bxCvFUlGXasfg3xuNFLhNQcpqtoxVYohrRm54SZvcQPMtObenJTd38KnsJKyWbdS9Af4svJyl5J1wbPj4SEtVj07/XXYkIys+oj9akrwqoNqRhRE9nMSDEN1anKD/HyLN6lzXUyIhsNXo2s31WXge/45F8dvBb6TjiNKNflPdVySTyXb7jGzF2uaBD/8hZgLkjQcrfOs9WAvi9cOe1/XQafn6FF+c0bEegy3RTw12V1hjn40+1Ci9agD0JUVlGazM+r07f59fMkmgUV6j4vyIn0mnzSyNismqnoTYSp8HpP+1+jhQPSOsW7MfERgpZBQ8bncNriP+lZp3kCQqOLhvgpFt5cjvUA6TEJenzopJw== X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1267;5:M2cS4HJDPuhixJ5uCY4YngsOlEK/So6vmpEjTcQXwdgNYGkR7tJKlLEC+pSG07RpkUtjPn2mIsEWyYQDia/p9OqgLbhvvgz3Rpcb2DM+sEI5S/39gSPKarAxL8atwoiJQPwf+9R6fL6OV9Q2dxUm3oT+gTr5kxnagFvw0E0v9BmasrTX/V3mdtkeJoN0a2HmGScFibpjKbxj1WlA9MsNozDWip0fAbCsIngiutmnkBarwvK4chnsVEfEAix8Qz23XpqqreQ/YsaBnf2e2NXUqzMav718pVZItWDLzZ9cBntnY8bsACibNBNI64qjHyN+Ymi7ytEH3JjxGHr3HXnP/LlR1t7ES/IVygQjF+zs8FXIN6xF6C58FuLOhBZ5TsK1IKTvs2EFFMvanbIj1E55UZyf1OlvA94M0o7E3GMYeq9j5D7R6XwdPZkvn+Ff/vrTYfcxKZnno0yUBNsndGqahTJEO33PaJTNzAYBxTuau3RhobFLM1RNlgUK4WsM3G7U;24:AVn35akino1+3p3Wt0j8eD5QozAFPTSKxFQd1hwbyTHECCrJGrLzkJGrpfh1x06aXi4pUxaqs2QA1I4z8E2AMidPS4AIfa43O1aszhztwUA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1267;7:5wALkDrwThAfPDQXfNmv7iZ+PDyTg5l8nY8Qu6GIFMGRHGipRklWQsXKw9UHj91cTRsN6Xgl5XIeR/0AlHNP8/svjfIul19lupnJ/oZSm/8BoW+dQxVPouN5/6KQeOVyandm4bsjt5AHpWiOMghQ9PT0xoodnG69zl7WCHR4r7s6AJFMP5KUgYpyGsRLbwoL4vwUXbcMHnQ7N19NArormLV1PLm+7cO6hRHKlYww5EBvgYQtx7PCxaKwj/Eb5CCra2EAqZtmmhG1nhWkE/TTktvDmzeYWvD7wtCIylF/BsTHvBlZqfSefCmXAVCPOL1P5Fl+EkzK12UgeAaDoBsDKg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2017 12:02:00.8862 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1267 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org They may be accessed from low-level code, so isolating is a measure to avoid circular dependencies in header files. The exact reason for circular dependency is WARN_ON() macro added in patch edd63a27 "set_restore_sigmask() is never called without SIGPENDING (and never should be)" Signed-off-by: Yury Norov --- include/linux/thread_bits.h | 63 +++++++++++++++++++++++++++++++++++++++++++ include/linux/thread_info.h | 66 +++++++++------------------------------------ 2 files changed, 75 insertions(+), 54 deletions(-) create mode 100644 include/linux/thread_bits.h diff --git a/include/linux/thread_bits.h b/include/linux/thread_bits.h new file mode 100644 index 000000000000..87354331bc7b --- /dev/null +++ b/include/linux/thread_bits.h @@ -0,0 +1,63 @@ +/* thread_bits.h: common low-level thread bits accessors */ + +#ifndef _LINUX_THREAD_BITS_H +#define _LINUX_THREAD_BITS_H + +#ifndef __ASSEMBLY__ + +#include +#include + +#ifdef CONFIG_THREAD_INFO_IN_TASK +/* + * For CONFIG_THREAD_INFO_IN_TASK kernels we need for the + * definition of current, but for !CONFIG_THREAD_INFO_IN_TASK kernels, + * including can cause a circular dependency on some platforms. + */ +#include +#define current_thread_info() ((struct thread_info *)current) +#endif + +/* + * flag set/clear/test wrappers + * - pass TIF_xxxx constants to these functions + */ + +static inline void set_ti_thread_flag(struct thread_info *ti, int flag) +{ + set_bit(flag, (unsigned long *)&ti->flags); +} + +static inline void clear_ti_thread_flag(struct thread_info *ti, int flag) +{ + clear_bit(flag, (unsigned long *)&ti->flags); +} + +static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag) +{ + return test_and_set_bit(flag, (unsigned long *)&ti->flags); +} + +static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag) +{ + return test_and_clear_bit(flag, (unsigned long *)&ti->flags); +} + +static inline int test_ti_thread_flag(struct thread_info *ti, int flag) +{ + return test_bit(flag, (unsigned long *)&ti->flags); +} + +#define set_thread_flag(flag) \ + set_ti_thread_flag(current_thread_info(), flag) +#define clear_thread_flag(flag) \ + clear_ti_thread_flag(current_thread_info(), flag) +#define test_and_set_thread_flag(flag) \ + test_and_set_ti_thread_flag(current_thread_info(), flag) +#define test_and_clear_thread_flag(flag) \ + test_and_clear_ti_thread_flag(current_thread_info(), flag) +#define test_thread_flag(flag) \ + test_ti_thread_flag(current_thread_info(), flag) + +#endif /* !__ASSEMBLY__ */ +#endif /* _LINUX_THREAD_BITS_H */ diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index d7d3ea637dd0..2467f350d659 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -7,9 +7,21 @@ #ifndef _LINUX_THREAD_INFO_H #define _LINUX_THREAD_INFO_H +/* + * For per-arch arch_within_stack_frames() implementations, defined in + * asm/thread_info.h. + */ +enum { + BAD_STACK = -1, + NOT_STACK = 0, + GOOD_FRAME, + GOOD_STACK, +}; + #include #include #include +#include #ifdef CONFIG_THREAD_INFO_IN_TASK /* @@ -21,19 +33,6 @@ #define current_thread_info() ((struct thread_info *)current) #endif -#include - -/* - * For per-arch arch_within_stack_frames() implementations, defined in - * asm/thread_info.h. - */ -enum { - BAD_STACK = -1, - NOT_STACK = 0, - GOOD_FRAME, - GOOD_STACK, -}; - #include #ifdef __KERNEL__ @@ -45,47 +44,6 @@ enum { # define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_NOTRACK) #endif -/* - * flag set/clear/test wrappers - * - pass TIF_xxxx constants to these functions - */ - -static inline void set_ti_thread_flag(struct thread_info *ti, int flag) -{ - set_bit(flag, (unsigned long *)&ti->flags); -} - -static inline void clear_ti_thread_flag(struct thread_info *ti, int flag) -{ - clear_bit(flag, (unsigned long *)&ti->flags); -} - -static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag) -{ - return test_and_set_bit(flag, (unsigned long *)&ti->flags); -} - -static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag) -{ - return test_and_clear_bit(flag, (unsigned long *)&ti->flags); -} - -static inline int test_ti_thread_flag(struct thread_info *ti, int flag) -{ - return test_bit(flag, (unsigned long *)&ti->flags); -} - -#define set_thread_flag(flag) \ - set_ti_thread_flag(current_thread_info(), flag) -#define clear_thread_flag(flag) \ - clear_ti_thread_flag(current_thread_info(), flag) -#define test_and_set_thread_flag(flag) \ - test_and_set_ti_thread_flag(current_thread_info(), flag) -#define test_and_clear_thread_flag(flag) \ - test_and_clear_ti_thread_flag(current_thread_info(), flag) -#define test_thread_flag(flag) \ - test_ti_thread_flag(current_thread_info(), flag) - #define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED) #ifndef CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES -- 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: ynorov@caviumnetworks.com (Yury Norov) Date: Sun, 4 Jun 2017 14:59:57 +0300 Subject: [PATCH 08/20] thread: move thread bits accessors to separated file In-Reply-To: <20170604120009.342-1-ynorov@caviumnetworks.com> References: <20170604120009.342-1-ynorov@caviumnetworks.com> Message-ID: <20170604120009.342-9-ynorov@caviumnetworks.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org They may be accessed from low-level code, so isolating is a measure to avoid circular dependencies in header files. The exact reason for circular dependency is WARN_ON() macro added in patch edd63a27 "set_restore_sigmask() is never called without SIGPENDING (and never should be)" Signed-off-by: Yury Norov --- include/linux/thread_bits.h | 63 +++++++++++++++++++++++++++++++++++++++++++ include/linux/thread_info.h | 66 +++++++++------------------------------------ 2 files changed, 75 insertions(+), 54 deletions(-) create mode 100644 include/linux/thread_bits.h diff --git a/include/linux/thread_bits.h b/include/linux/thread_bits.h new file mode 100644 index 000000000000..87354331bc7b --- /dev/null +++ b/include/linux/thread_bits.h @@ -0,0 +1,63 @@ +/* thread_bits.h: common low-level thread bits accessors */ + +#ifndef _LINUX_THREAD_BITS_H +#define _LINUX_THREAD_BITS_H + +#ifndef __ASSEMBLY__ + +#include +#include + +#ifdef CONFIG_THREAD_INFO_IN_TASK +/* + * For CONFIG_THREAD_INFO_IN_TASK kernels we need for the + * definition of current, but for !CONFIG_THREAD_INFO_IN_TASK kernels, + * including can cause a circular dependency on some platforms. + */ +#include +#define current_thread_info() ((struct thread_info *)current) +#endif + +/* + * flag set/clear/test wrappers + * - pass TIF_xxxx constants to these functions + */ + +static inline void set_ti_thread_flag(struct thread_info *ti, int flag) +{ + set_bit(flag, (unsigned long *)&ti->flags); +} + +static inline void clear_ti_thread_flag(struct thread_info *ti, int flag) +{ + clear_bit(flag, (unsigned long *)&ti->flags); +} + +static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag) +{ + return test_and_set_bit(flag, (unsigned long *)&ti->flags); +} + +static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag) +{ + return test_and_clear_bit(flag, (unsigned long *)&ti->flags); +} + +static inline int test_ti_thread_flag(struct thread_info *ti, int flag) +{ + return test_bit(flag, (unsigned long *)&ti->flags); +} + +#define set_thread_flag(flag) \ + set_ti_thread_flag(current_thread_info(), flag) +#define clear_thread_flag(flag) \ + clear_ti_thread_flag(current_thread_info(), flag) +#define test_and_set_thread_flag(flag) \ + test_and_set_ti_thread_flag(current_thread_info(), flag) +#define test_and_clear_thread_flag(flag) \ + test_and_clear_ti_thread_flag(current_thread_info(), flag) +#define test_thread_flag(flag) \ + test_ti_thread_flag(current_thread_info(), flag) + +#endif /* !__ASSEMBLY__ */ +#endif /* _LINUX_THREAD_BITS_H */ diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index d7d3ea637dd0..2467f350d659 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -7,9 +7,21 @@ #ifndef _LINUX_THREAD_INFO_H #define _LINUX_THREAD_INFO_H +/* + * For per-arch arch_within_stack_frames() implementations, defined in + * asm/thread_info.h. + */ +enum { + BAD_STACK = -1, + NOT_STACK = 0, + GOOD_FRAME, + GOOD_STACK, +}; + #include #include #include +#include #ifdef CONFIG_THREAD_INFO_IN_TASK /* @@ -21,19 +33,6 @@ #define current_thread_info() ((struct thread_info *)current) #endif -#include - -/* - * For per-arch arch_within_stack_frames() implementations, defined in - * asm/thread_info.h. - */ -enum { - BAD_STACK = -1, - NOT_STACK = 0, - GOOD_FRAME, - GOOD_STACK, -}; - #include #ifdef __KERNEL__ @@ -45,47 +44,6 @@ enum { # define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_NOTRACK) #endif -/* - * flag set/clear/test wrappers - * - pass TIF_xxxx constants to these functions - */ - -static inline void set_ti_thread_flag(struct thread_info *ti, int flag) -{ - set_bit(flag, (unsigned long *)&ti->flags); -} - -static inline void clear_ti_thread_flag(struct thread_info *ti, int flag) -{ - clear_bit(flag, (unsigned long *)&ti->flags); -} - -static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag) -{ - return test_and_set_bit(flag, (unsigned long *)&ti->flags); -} - -static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag) -{ - return test_and_clear_bit(flag, (unsigned long *)&ti->flags); -} - -static inline int test_ti_thread_flag(struct thread_info *ti, int flag) -{ - return test_bit(flag, (unsigned long *)&ti->flags); -} - -#define set_thread_flag(flag) \ - set_ti_thread_flag(current_thread_info(), flag) -#define clear_thread_flag(flag) \ - clear_ti_thread_flag(current_thread_info(), flag) -#define test_and_set_thread_flag(flag) \ - test_and_set_ti_thread_flag(current_thread_info(), flag) -#define test_and_clear_thread_flag(flag) \ - test_and_clear_ti_thread_flag(current_thread_info(), flag) -#define test_thread_flag(flag) \ - test_ti_thread_flag(current_thread_info(), flag) - #define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED) #ifndef CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES -- 2.11.0