From patchwork Wed Mar 16 23:15:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12783258 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26B0DC4332F for ; Wed, 16 Mar 2022 23:15:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D3536B0072; Wed, 16 Mar 2022 19:15:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AAC16B0073; Wed, 16 Mar 2022 19:15:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 872E08D0001; Wed, 16 Mar 2022 19:15:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 784106B0072 for ; Wed, 16 Mar 2022 19:15:07 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2C2D295B10 for ; Wed, 16 Mar 2022 23:15:07 +0000 (UTC) X-FDA: 79251807054.29.064678F Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf08.hostedemail.com (Postfix) with ESMTP id BDB4916000B for ; Wed, 16 Mar 2022 23:15:05 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2DA7DB81C4D; Wed, 16 Mar 2022 23:15:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA1FBC340EC; Wed, 16 Mar 2022 23:15:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647472504; bh=zNSaguHsQ0Z2gT5BRDht4ZRF2pSwkFvPw/VCK/fS2rU=; h=Date:To:From:In-Reply-To:Subject:From; b=WfHu4NO17kX+/KhtTIvQHFzwpu5wxJJ+ipBYzR5NyJq1qql8RTKchjaSTFWTbkJ2s hAmTBubEv/TovifNCu8wbqskdLRjNga9Xut243aQTJ9qp4z+4A7I/ApL3UTdyEd4S2 Sqe25MYVTXlQlt66X4bcll6swxs6Frct8dIVQO60= Date: Wed, 16 Mar 2022 16:15:03 -0700 To: zealci@zte.com.cn,yang.yang29@zte.com.cn,stable@vger.kernel.org,rogerq@kernel.org,ran.xiaokai@zte.com.cn,naoya.horiguchi@nec.com,minchan@kernel.org,mhocko@kernel.org,jiang.xuexin@zte.com.cn,hughd@google.com,hannes@cmpxchg.org,guo.ziliang@zte.com.cn,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220316161433.5c2e137a69eaee50d2249a27@linux-foundation.org> Subject: [patch 1/4] mm: swap: get rid of deadloop in swapin readahead Message-Id: <20220316231503.DA1FBC340EC@smtp.kernel.org> X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BDB4916000B X-Stat-Signature: 8dn3q4poos3snqgiydjrm1oy7ng6ec6f Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=WfHu4NO1; dmarc=none; spf=pass (imf08.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1647472505-853525 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Guo Ziliang Subject: mm: swap: get rid of deadloop in swapin readahead In our testing, a deadloop task was found. Through sysrq printing, same stack was found every time, as follows: __swap_duplicate+0x58/0x1a0 swapcache_prepare+0x24/0x30 __read_swap_cache_async+0xac/0x220 read_swap_cache_async+0x58/0xa0 swapin_readahead+0x24c/0x628 do_swap_page+0x374/0x8a0 __handle_mm_fault+0x598/0xd60 handle_mm_fault+0x114/0x200 do_page_fault+0x148/0x4d0 do_translation_fault+0xb0/0xd4 do_mem_abort+0x50/0xb0 The reason for the deadloop is that swapcache_prepare() always returns EEXIST, indicating that SWAP_HAS_CACHE has not been cleared, so that it cannot jump out of the loop. We suspect that the task that clears the SWAP_HAS_CACHE flag never gets a chance to run. We try to lower the priority of the task stuck in a deadloop so that the task that clears the SWAP_HAS_CACHE flag will run. The results show that the system returns to normal after the priority is lowered. In our testing, multiple real-time tasks are bound to the same core, and the task in the deadloop is the highest priority task of the core, so the deadloop task cannot be preempted. Although cond_resched() is used by __read_swap_cache_async, it is an empty function in the preemptive system and cannot achieve the purpose of releasing the CPU. A high-priority task cannot release the CPU unless preempted by a higher-priority task. But when this task is already the highest priority task on this core, other tasks will not be able to be scheduled. So we think we should replace cond_resched() with schedule_timeout_uninterruptible(1), schedule_timeout_interruptible will call set_current_state first to set the task state, so the task will be removed from the running queue, so as to achieve the purpose of giving up the CPU and prevent it from running in kernel mode for too long. (akpm: ugly hack becomes uglier. But it fixes the issue in a backportable-to-stable fashion while we hopefully work on something better) Link: https://lkml.kernel.org/r/20220221111749.1928222-1-cgel.zte@gmail.com Signed-off-by: Guo Ziliang Reported-by: Zeal Robot Reviewed-by: Ran Xiaokai Reviewed-by: Jiang Xuexin Reviewed-by: Yang Yang Acked-by: Hugh Dickins Cc: Naoya Horiguchi Cc: Michal Hocko Cc: Minchan Kim Cc: Johannes Weiner Cc: Roger Quadros Cc: Ziliang Guo Cc: Signed-off-by: Andrew Morton --- mm/swap_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/swap_state.c~mm-swap-get-rid-of-deadloop-in-swapin-readahead +++ a/mm/swap_state.c @@ -478,7 +478,7 @@ struct page *__read_swap_cache_async(swp * __read_swap_cache_async(), which has set SWAP_HAS_CACHE * in swap_map, but not yet added its page to swap cache. */ - cond_resched(); + schedule_timeout_uninterruptible(1); } /* From patchwork Wed Mar 16 23:15:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12783260 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1152C433FE for ; Wed, 16 Mar 2022 23:15:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD2826B0074; Wed, 16 Mar 2022 19:15:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B7F626B0075; Wed, 16 Mar 2022 19:15:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FA7F8D0001; Wed, 16 Mar 2022 19:15:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 83C4B6B0075 for ; Wed, 16 Mar 2022 19:15:13 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 47E5895B10 for ; Wed, 16 Mar 2022 23:15:13 +0000 (UTC) X-FDA: 79251807306.24.712BD1F Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf26.hostedemail.com (Postfix) with ESMTP id 2EDE114000E for ; Wed, 16 Mar 2022 23:15:12 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id D40DDCE21CF; Wed, 16 Mar 2022 23:15:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB2A8C340F0; Wed, 16 Mar 2022 23:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647472507; bh=GcbgBfbmdsgKzXYTotfD37FdjeSjVzjYMevfGpeN48U=; h=Date:To:From:In-Reply-To:Subject:From; b=UcxSdmHklPhA0lec5rKi8nepTAqNQalUOLmo21EJ1Z7EsJaiK+1JJ3ECBHpPOx3DS yKO+uEilLu/DQWXeH7NqbNoB3/ke/jA8H7RToPyV4OVEES+WYWGKnmBEKypZdeUrIC j8HpIDMVDDVXrwwuuyhLKeCYZQ46bCJWY07rRYN4= Date: Wed, 16 Mar 2022 16:15:06 -0700 To: keescook@chromium.org,daniel.thompson@linaro.org,quic_qiancai@quicinc.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220316161433.5c2e137a69eaee50d2249a27@linux-foundation.org> Subject: [patch 2/4] configs/debug: restore DEBUG_INFO=y for overriding Message-Id: <20220316231506.EB2A8C340F0@smtp.kernel.org> X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2EDE114000E Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=UcxSdmHk; spf=pass (imf26.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Stat-Signature: h8mrqsxgcy4bt95bsxmr4jmzeeerfokd X-HE-Tag: 1647472512-246411 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Qian Cai Subject: configs/debug: restore DEBUG_INFO=y for overriding Previously, I failed to realize that Kees' patch [1] has not been merged into the mainline yet, and dropped DEBUG_INFO=y too eagerly from the mainline. As the results, "make debug.config" won't be able to flip DEBUG_INFO=n from the existing .config. This should close the gaps of a few weeks before Kees' patch is there, and work regardless of their merging status anyway. [1] https://lore.kernel.org/all/20220125075126.891825-1-keescook@chromium.org/ Link: https://lkml.kernel.org/r/20220308153524.8618-1-quic_qiancai@quicinc.com Signed-off-by: Qian Cai Reported-by: Daniel Thompson Reviewed-by: Daniel Thompson Cc: Kees Cook Signed-off-by: Andrew Morton --- kernel/configs/debug.config | 1 + 1 file changed, 1 insertion(+) --- a/kernel/configs/debug.config~configs-debug-restore-debug_info=y-for-overriding +++ a/kernel/configs/debug.config @@ -16,6 +16,7 @@ CONFIG_SYMBOLIC_ERRNAME=y # # Compile-time checks and compiler options # +CONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y CONFIG_DEBUG_SECTION_MISMATCH=y CONFIG_FRAME_WARN=2048 From patchwork Wed Mar 16 23:15:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12783259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA943C433F5 for ; Wed, 16 Mar 2022 23:15:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C6B86B0073; Wed, 16 Mar 2022 19:15:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6769E6B0074; Wed, 16 Mar 2022 19:15:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53EBA8D0001; Wed, 16 Mar 2022 19:15:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 450156B0073 for ; Wed, 16 Mar 2022 19:15:13 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0F9911483 for ; Wed, 16 Mar 2022 23:15:13 +0000 (UTC) X-FDA: 79251807306.09.D383CA1 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf08.hostedemail.com (Postfix) with ESMTP id B42A2160012 for ; Wed, 16 Mar 2022 23:15:11 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 47272B81C52; Wed, 16 Mar 2022 23:15:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02CBFC340EC; Wed, 16 Mar 2022 23:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647472510; bh=I3KlzWWISu6bKc3RthGyJbP6gMdZJBgq9UqJ9Av16mM=; h=Date:To:From:In-Reply-To:Subject:From; b=rQWetDYlla979RjnU6/jYv2CDSyz2S9rUL1zYPf4AUoCtXjz8fkya/CzLMJlIiqsp a3jhMwFJWROEIKerIT086VvPlsgXODRdlSrNlso4Sq/o1hIhZYle/YTgryHyFr2OdE AghCBBb+THzaIcERiw8tYCo09XU8GK/jEmcGrZj0= Date: Wed, 16 Mar 2022 16:15:09 -0700 To: stable@vger.kernel.org,piaojun@huawei.com,mark@fasheh.com,junxiao.bi@oracle.com,jlbec@evilplan.org,ghe@suse.com,gechangwei@live.cn,joseph.qi@linux.alibaba.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220316161433.5c2e137a69eaee50d2249a27@linux-foundation.org> Subject: [patch 3/4] ocfs2: fix crash when initialize filecheck kobj fails Message-Id: <20220316231510.02CBFC340EC@smtp.kernel.org> X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=rQWetDYl; dmarc=none; spf=pass (imf08.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: B42A2160012 X-Stat-Signature: ruj1r8e1efyu5woydh55puhryz5tdx37 X-HE-Tag: 1647472511-206646 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Joseph Qi Subject: ocfs2: fix crash when initialize filecheck kobj fails Once s_root is set, genric_shutdown_super() will be called if fill_super() fails. That means, we will call ocfs2_dismount_volume() twice in such case, which can lead to kernel crash. Fix this issue by initializing filecheck kobj before setting s_root. Link: https://lkml.kernel.org/r/20220310081930.86305-1-joseph.qi@linux.alibaba.com Fixes: 5f483c4abb50 ("ocfs2: add kobject for online file check") Signed-off-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Gang He Cc: Jun Piao Cc: Signed-off-by: Andrew Morton --- fs/ocfs2/super.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) --- a/fs/ocfs2/super.c~ocfs2-fix-crash-when-initialize-filecheck-kobj-fails +++ a/fs/ocfs2/super.c @@ -1105,17 +1105,6 @@ static int ocfs2_fill_super(struct super goto read_super_error; } - root = d_make_root(inode); - if (!root) { - status = -ENOMEM; - mlog_errno(status); - goto read_super_error; - } - - sb->s_root = root; - - ocfs2_complete_mount_recovery(osb); - osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL, &ocfs2_kset->kobj); if (!osb->osb_dev_kset) { @@ -1133,6 +1122,17 @@ static int ocfs2_fill_super(struct super goto read_super_error; } + root = d_make_root(inode); + if (!root) { + status = -ENOMEM; + mlog_errno(status); + goto read_super_error; + } + + sb->s_root = root; + + ocfs2_complete_mount_recovery(osb); + if (ocfs2_mount_local(osb)) snprintf(nodestr, sizeof(nodestr), "local"); else From patchwork Wed Mar 16 23:15:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12783261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F27ECC4332F for ; Wed, 16 Mar 2022 23:15:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51BAD6B0075; Wed, 16 Mar 2022 19:15:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C8A56B0078; Wed, 16 Mar 2022 19:15:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 343088D0001; Wed, 16 Mar 2022 19:15:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id 2142D6B0075 for ; Wed, 16 Mar 2022 19:15:16 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D95D418249F8D for ; Wed, 16 Mar 2022 23:15:15 +0000 (UTC) X-FDA: 79251807390.25.835765E Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf27.hostedemail.com (Postfix) with ESMTP id 6F77A4000F for ; Wed, 16 Mar 2022 23:15:14 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 512E0B81C4F; Wed, 16 Mar 2022 23:15:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12D5CC340EC; Wed, 16 Mar 2022 23:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647472513; bh=KKfKFCFFI9do0CYmJ+65JyVaazlU6mir1V03pLXZitA=; h=Date:To:From:In-Reply-To:Subject:From; b=xZ6oJuFhUrwmb5aru3J7Nv9+gGoVAn4U+0OHQFAmhFdqH7qHF6oqR4uTwLyLtd/fJ +aUabMBqN0JqB8DQ8Q+Z1Fef4FKxUZfCM3FewBKhDf5MH81s6Wntzm0606SHJAXGed 0TDAje3dpcXFVMdsapueKNrXguoXLfqZdo+nolI8= Date: Wed, 16 Mar 2022 16:15:12 -0700 To: shuah@kernel.org,ndesaulniers@google.com,nathan@kernel.org,yosryahmed@google.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220316161433.5c2e137a69eaee50d2249a27@linux-foundation.org> Subject: [patch 4/4] selftests: vm: fix clang build error multiple output files Message-Id: <20220316231513.12D5CC340EC@smtp.kernel.org> X-Rspamd-Queue-Id: 6F77A4000F X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=xZ6oJuFh; spf=pass (imf27.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: anqsidr6umba7pz5sokgt87upiii9rug X-Rspamd-Server: rspam07 X-HE-Tag: 1647472514-263969 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Yosry Ahmed Subject: selftests: vm: fix clang build error multiple output files When building the vm selftests using clang, some errors are seen due to having headers in the compilation command: clang -Wall -I ../../../../usr/include -no-pie gup_test.c ../../../../mm/gup_test.h -lrt -lpthread -o .../tools/testing/selftests/vm/gup_test clang: error: cannot specify -o when generating multiple output files make[1]: *** [../lib.mk:146: .../tools/testing/selftests/vm/gup_test] Error 1 Rework to add the header files to LOCAL_HDRS before including ../lib.mk, since the dependency is evaluated in '$(OUTPUT)/%:%.c $(LOCAL_HDRS)' in file lib.mk. Link: https://lkml.kernel.org/r/20220304000645.1888133-1-yosryahmed@google.com Signed-off-by: Yosry Ahmed Cc: Shuah Khan Cc: Nathan Chancellor Cc: Nick Desaulniers Signed-off-by: Andrew Morton --- tools/testing/selftests/vm/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/tools/testing/selftests/vm/Makefile~selftests-vm-fix-clang-build-error-multiple-output-files +++ a/tools/testing/selftests/vm/Makefile @@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for vm selftests +LOCAL_HDRS += $(selfdir)/vm/local_config.h $(top_srcdir)/mm/gup_test.h + include local_config.mk uname_M := $(shell uname -m 2>/dev/null || echo not) @@ -140,10 +142,6 @@ endif $(OUTPUT)/mlock-random-test $(OUTPUT)/memfd_secret: LDLIBS += -lcap -$(OUTPUT)/gup_test: ../../../../mm/gup_test.h - -$(OUTPUT)/hmm-tests: local_config.h - # HMM_EXTRA_LIBS may get set in local_config.mk, or it may be left empty. $(OUTPUT)/hmm-tests: LDLIBS += $(HMM_EXTRA_LIBS)