From patchwork Thu Feb 8 10:05:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang Xu \\(Fujitsu\\)" X-Patchwork-Id: 1896518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lists.linux.it header.i=@lists.linux.it header.a=rsa-sha256 header.s=picard header.b=fSHd5+5N; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=FB32jb5M; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TVt0J38rsz23hn for ; Thu, 8 Feb 2024 21:05:36 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it; i=@lists.linux.it; q=dns/txt; s=picard; t=1707386733; h=to : date : message-id : mime-version : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : from : reply-to : content-type : content-transfer-encoding : sender : from; bh=2MCo0NkQvory78jKCzpAUSsBnv9g5dWfV96my/qheuU=; b=fSHd5+5NLdvE1zQsWJ1EKk4Vui6M/u3lr7lx4rz85DEf1O0g7CWACWlAO0RwOSFDfrkCX kWh2Kr/elq+fuPlcKODEgrjz1ZX7ycOZLVLkzd8BEF88dirZXzmGVHA4xdNCSjxgbLtUVy7 uaWbg5ETg6wiv3j43QkIWdRsNJbJpac= Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 53C3A3CCAB2 for ; Thu, 8 Feb 2024 11:05:33 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id AB7783C5AC4 for ; Thu, 8 Feb 2024 11:05:29 +0100 (CET) Authentication-Results: in-4.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=fujitsu.com (client-ip=207.54.90.49; helo=esa3.hc1455-7.c3s2.iphmx.com; envelope-from=xuyang2018.jy@fujitsu.com; receiver=lists.linux.it) Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id D593B10007C8 for ; Thu, 8 Feb 2024 11:05:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1707386729; x=1738922729; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=aoo6e7YB5WUi7e4/CXc3LxRG8k+mnAbenAjM5A2LngU=; b=FB32jb5MN6ikL+kvO2+3kpJTFvsRN2Pt7coubsV70fGUlFoHCfP13l4b pEJWKYnBH/9Eecpz3D5k/aF7tVK1EpJl0SQ8EHt5P7ZgrSmZyVdnoM7vZ chrMOmtdRPNdGpHs5OLo3DTVydxExygdrZZYVT4P/ZOp9EcwC8AzCN2Hf OSHpECLb81Ak1Q3k97opj1E6/ZzrxwJEHRv3twqllCd8lWmOGBfk2TeRp Ayqp5zbOaKcg9z1LRn8yIonWO1fiLLYMlLBMj48Hem6QF6cgYcVvgyYJi LfXQHKZnaDKYpFmvl9E03f2iZxZlzZ/7xh/fTk3u2vemmKkagAS4DQqj1 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="148804453" X-IronPort-AV: E=Sophos;i="6.05,253,1701097200"; d="scan'208";a="148804453" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 19:05:26 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id B79A38BF0F for ; Thu, 8 Feb 2024 19:05:23 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 01FF8F31B0 for ; Thu, 8 Feb 2024 19:05:23 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 888D341043 for ; Thu, 8 Feb 2024 19:05:22 +0900 (JST) Received: from rhel93GA.g08.fujitsu.local (unknown [10.167.221.71]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 16BCA1A009A; Thu, 8 Feb 2024 18:05:21 +0800 (CST) To: ltp@lists.linux.it Date: Thu, 8 Feb 2024 05:05:11 -0500 Message-Id: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28178.003 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28178.003 X-TMASE-Result: 10--8.914200-10.000000 X-TMASE-MatchedRID: toN6SH028bXlWiNI/3lAD79A3Bl1/DcVTFQnI+epPIZCw17cr3HRBx/X wLPL3ezhMqXIprsw7E8foWaqRA7iyogrKnsJ1GRgTuctSpiuWyUUi4Ehat05499RlPzeVuQQXfA pMkKyKiOTas0OGgVW2UDzPxrZuPWDDPIzF4wRfrAURSScn+QSXt0H8LFZNFG7bkV4e2xSge7mIH WMNYTzgK7rh8uDUM1wdgK03GLUbYHoMkReFyp1CsWFcyN1Agmm X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-4.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 1/7] libltpswap: Add tst_max_swapfiles api X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yang Xu via ltp From: "Yang Xu \\(Fujitsu\\)" Reply-To: Yang Xu Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Current, the kernel constant MAX_SWAPFILES value is calculated as below ------------------------------------ //#ifdef CONFIG_DEVICE_PRIVATE //#define SWP_DEVICE_NUM 4 //#else //#define SWP_DEVICE_NUM 0 //#endif //#ifdef CONFIG_MIGRATION //#define SWP_MIGRATION_NUM 3 //#else //#define SWP_MIGRATION_NUM 0 //#ifdef CONFIG_MEMORY_FAILURE //#define SWP_HWPOISON_NUM 1 //#else //#define SWP_HWPOISON_NUM 0 //#endif //#define SWP_PTE_MARKER_NUM 1 //#define MAX_SWAPFILES_SHIFT 5 //#define MAX_SWAPFILES \ // ((1 << MAX_SWAPFILES_SHIFT) - SWP_DEVICE_NUM - \ // SWP_MIGRATION_NUM - SWP_HWPOISON_NUM - \ // SWP_PTE_MARKER_NUM) ------------------------------------ Also, man-pages missed something after 5.14 kernel. I have sent two patches[1][2] to add it. The kernel patches modify this kernel constant in[3][4][5][6]. [1]https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=26f3ec74e [2]https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=6bf3937fc [3]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/linux/swap.h?id=5042db43cc [4]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/linux/swap.h?id=b756a3b5e [5]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/linux/swap.h?id=679d10331 [6]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/linux/swap.h?id=6c287605f Signed-off-by: Yang Xu --- include/libswap.h | 6 ++++++ libs/libltpswap/libswap.c | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/include/libswap.h b/include/libswap.h index bdc5aacc6..361d73175 100644 --- a/include/libswap.h +++ b/include/libswap.h @@ -21,4 +21,10 @@ int make_swapfile(const char *swapfile, int blocks, int safe); * we are testing on. */ bool is_swap_supported(const char *filename); + +/* + * Get kernel constant MAX_SWAPFILES value + */ +int tst_max_swapfiles(void); + #endif /* __LIBSWAP_H__ */ diff --git a/libs/libltpswap/libswap.c b/libs/libltpswap/libswap.c index c79de19d7..69273fb33 100644 --- a/libs/libltpswap/libswap.c +++ b/libs/libltpswap/libswap.c @@ -16,6 +16,8 @@ #include "tst_test.h" #include "libswap.h" #include "lapi/syscalls.h" +#include "tst_kconfig.h" +#include "tst_safe_stdio.h" static const char *const swap_supported_fs[] = { "btrfs", @@ -217,3 +219,45 @@ bool is_swap_supported(const char *filename) return true; } + +/* + * Get kernel constant MAX_SWAPFILES value + */ +int tst_max_swapfiles(void) +{ + unsigned int max_swapfile = 32; + unsigned int swp_migration_num = 0, swp_hwpoison_num = 0, swp_device_num = 0, swp_pte_marker_num = 0; + struct tst_kconfig_var migration_kconfig = TST_KCONFIG_INIT("CONFIG_MIGRATION"); + struct tst_kconfig_var memory_kconfig = TST_KCONFIG_INIT("CONFIG_MEMORY_FAILURE"); + struct tst_kconfig_var device_kconfig = TST_KCONFIG_INIT("CONFIG_DEVICE_PRIVATE"); + struct tst_kconfig_var marker_kconfig = TST_KCONFIG_INIT("CONFIG_PTE_MARKER"); + + tst_kconfig_read(&migration_kconfig, 1); + tst_kconfig_read(&memory_kconfig, 1); + tst_kconfig_read(&device_kconfig, 1); + tst_kconfig_read(&marker_kconfig, 1); + + if (migration_kconfig.choice == 'y') { + if (tst_kvercmp(5, 19, 0) < 0) + swp_migration_num = 2; + else + swp_migration_num = 3; + } + + if (memory_kconfig.choice == 'y') + swp_hwpoison_num = 1; + + if (device_kconfig.choice == 'y') { + if (tst_kvercmp(4, 14, 0) >= 0) + swp_device_num = 2; + if (tst_kvercmp(5, 14, 0) >= 0) + swp_device_num = 4; + } + + if (marker_kconfig.choice == 'y') { + if (tst_kvercmp(5, 19, 0) >= 0) + swp_pte_marker_num = 1; + } + + return max_swapfile - swp_migration_num - swp_hwpoison_num - swp_device_num - swp_pte_marker_num; +} From patchwork Thu Feb 8 10:05:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang Xu \\(Fujitsu\\)" X-Patchwork-Id: 1896519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lists.linux.it header.i=@lists.linux.it header.a=rsa-sha256 header.s=picard header.b=QKB4rOHP; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=KLWapVVf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TVt0n2PBNz23hn for ; Thu, 8 Feb 2024 21:06:01 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it; i=@lists.linux.it; q=dns/txt; s=picard; t=1707386758; h=to : date : message-id : in-reply-to : references : mime-version : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : from : reply-to : content-type : content-transfer-encoding : sender : from; bh=hT3JAf1BKTW+hFSVGdPy/ZxsXJwkCc6ORvmRnoAXeYU=; b=QKB4rOHP2EQAtY5PQ06FQLPo3NQN2VUVNzbc3/rS8zvoKT6Cn+XLV2CPVETuwCrwNTiPv r7LTRGYKe+QdUgLu6cTIPI/GC3g+9h36/pAwFKB0yen3vMPKy4U4KCQAU/Le8U1rbRZr6UE 4f2ruC8NZbDROtOc9mUBbHLXgmiH1BY= Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E262A3CC4C0 for ; Thu, 8 Feb 2024 11:05:58 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id B42643CC3F8 for ; Thu, 8 Feb 2024 11:05:44 +0100 (CET) Authentication-Results: in-2.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=fujitsu.com (client-ip=68.232.139.139; helo=esa6.hc1455-7.c3s2.iphmx.com; envelope-from=xuyang2018.jy@fujitsu.com; receiver=lists.linux.it) Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 9F13B62D1BF for ; Thu, 8 Feb 2024 11:05:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1707386744; x=1738922744; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ktiSQZDyWKq+KTCoyBVIXAF0Qx1vJ+5tvJKqMd+Hu1A=; b=KLWapVVfMIgLdVORwljAunqQDel2xTbMRa9uWhrqgkFWNgI7y0NpnJQF pcvJizF5if8u5EoL5rGSExIVKNo0w2S8lgtvJ5vdjgsUQeWW+jHZqkMhx r8/j7LuPrsAjMz4FqhI7y5aDaKrumlziVDzlDWTi+I+xeM02gdhYfKpZT PVgqGl+GDliZ9m55hOLydYP/v3srFoMILcwzNPpbSM/D+PNCu75plWQ+Q Hl33CHer6bL3JTVe8sOPxr7bGGORoLho6+ZF+Wcq8PEVn9aJQ3zgPtyfM wjHuYSraBuPiF9emzIUnN5uhDybIvuGDFLoGuCgNOCKfL+nwT8UUjuhqK w==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="150538907" X-IronPort-AV: E=Sophos;i="6.05,253,1701097200"; d="scan'208";a="150538907" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 19:05:41 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 036C82EBE5 for ; Thu, 8 Feb 2024 19:05:39 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 2C2C7108615 for ; Thu, 8 Feb 2024 19:05:38 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id AEA7120097CDF for ; Thu, 8 Feb 2024 19:05:37 +0900 (JST) Received: from rhel93GA.g08.fujitsu.local (unknown [10.167.221.71]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 5EC941A009A; Thu, 8 Feb 2024 18:05:37 +0800 (CST) To: ltp@lists.linux.it Date: Thu, 8 Feb 2024 05:05:12 -0500 Message-Id: <20240208100517.1974-2-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> References: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28178.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28178.004 X-TMASE-Result: 10--8.247500-10.000000 X-TMASE-MatchedRID: wrMmQdWyhqi9TGmwrVcPSwXtykVcrvpNCZa9cSpBObnAuQ0xDMaXkH4q tYI9sRE/Vztt14qydotC2s0bIz7TOS0+EsApCrRRutvHF25zoU9MVCcj56k8hq25ZjP2hWgveWw Yle3v1YxzzWLzuR3HAoAy6p60ZV62yA7duzCw6dLdB/CxWTRRu25FeHtsUoHuA5Xvjc0oM39LD/ cYBN+IRDIHQ2VDQ28kD04nabZL6su+68HqACCvKA== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-2.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 2/7] libltpswap: alter tst_count_swaps api X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yang Xu via ltp From: "Yang Xu \\(Fujitsu\\)" Reply-To: Yang Xu Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Like we count the ipc resource total, we can also add a similar api for swapfiles, so we can use it for swapon03 case. Signed-off-by: Yang Xu --- include/libswap.h | 5 +++++ libs/libltpswap/libswap.c | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/libswap.h b/include/libswap.h index 361d73175..76a3ed0c0 100644 --- a/include/libswap.h +++ b/include/libswap.h @@ -27,4 +27,9 @@ bool is_swap_supported(const char *filename); */ int tst_max_swapfiles(void); +/* + * Get the used swapfiles number + */ +int tst_count_swaps(void); + #endif /* __LIBSWAP_H__ */ diff --git a/libs/libltpswap/libswap.c b/libs/libltpswap/libswap.c index 69273fb33..fa0d42543 100644 --- a/libs/libltpswap/libswap.c +++ b/libs/libltpswap/libswap.c @@ -261,3 +261,30 @@ int tst_max_swapfiles(void) return max_swapfile - swp_migration_num - swp_hwpoison_num - swp_device_num - swp_pte_marker_num; } + +/* + * Get the used swapfiles number + */ +int tst_count_swaps(void) +{ + FILE *fp; + int used = -1; + char c; + + fp = fopen("/proc/swaps", "r"); + if (fp == NULL) { + return -1; + } + + while ((c = fgetc(fp)) != EOF) { + if (c == '\n') + used++; + } + + fclose(fp); + if (used < 0) { + tst_brk(TBROK, "can't read /proc/swaps to get used swapfiles resource total "); + } + + return used; +} From patchwork Thu Feb 8 10:05:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang Xu \\(Fujitsu\\)" X-Patchwork-Id: 1896520 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lists.linux.it header.i=@lists.linux.it header.a=rsa-sha256 header.s=picard header.b=XK8vr6Vl; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=dxNitSnv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TVt1D57v7z23hn for ; Thu, 8 Feb 2024 21:06:24 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it; i=@lists.linux.it; q=dns/txt; s=picard; t=1707386782; h=to : date : message-id : in-reply-to : references : mime-version : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : from : reply-to : content-type : content-transfer-encoding : sender : from; bh=sl97hEf4E9h05gdM+CwR1jRFCk0RUimt40NUFSgppMg=; b=XK8vr6VlXCuO0yolAc2u766Wa4Hx9AbncRBNWARid+e0b9+CljHl2OTGPKEkQkw8bOUWv tdWHN6KPpgogeiCY3PM8WN2MqqS7aB52uIxN1q6FtuxerxhE+5dTNhoYlw5GmeoA2cK5wnK DEXvYk41sPPpjDwzQZxK6kG4N+TiGmI= Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AE97F3CC4B5 for ; Thu, 8 Feb 2024 11:06:22 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 2F56A3CE538 for ; Thu, 8 Feb 2024 11:05:44 +0100 (CET) Authentication-Results: in-7.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=fujitsu.com (client-ip=207.54.90.137; helo=esa11.hc1455-7.c3s2.iphmx.com; envelope-from=xuyang2018.jy@fujitsu.com; receiver=lists.linux.it) Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 54C5420B243 for ; Thu, 8 Feb 2024 11:05:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1707386744; x=1738922744; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Mwun/td6J2vKl1zAAizbeEkl/1YILJqXhSY5LnvnoR4=; b=dxNitSnvBOpsJWsG+GccQrU+1yHgbs8bbt1+R2XMZA/+ca+DF2fS6rnm ZDqAzd300wgnCQjkAqFH5/3lxR7vaSAtDtP8BANsHZ21dm0xxOHbroK3F DVEOk8OBBB0fYf/Ew57M6qAWDdLT/4DyYWfBgBigbm51q6BlSNATuphaU OTjRVCEfRPo+uAXfZwZJxWWw38IhRBgxEp9nPD9GJcAVI3jka9uT5+tIj RsceyC0rZGOxRvUo5Cm6LDmNU/e2HKZgQdjI2eOmqo1vwtOkJ5Lms5bUs atM2WmGrd4F18ueFGY8+gVw0WRWvG9GVHn9tGoVP57Z7CN2ljK4MW53Mr w==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="128200584" X-IronPort-AV: E=Sophos;i="6.05,253,1701097200"; d="scan'208";a="128200584" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 19:05:42 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id DEA34123045 for ; Thu, 8 Feb 2024 19:05:39 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 29D67D5928 for ; Thu, 8 Feb 2024 19:05:39 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 9611041043 for ; Thu, 8 Feb 2024 19:05:38 +0900 (JST) Received: from rhel93GA.g08.fujitsu.local (unknown [10.167.221.71]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 49C071A009A; Thu, 8 Feb 2024 18:05:38 +0800 (CST) To: ltp@lists.linux.it Date: Thu, 8 Feb 2024 05:05:13 -0500 Message-Id: <20240208100517.1974-3-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> References: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28178.003 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28178.003 X-TMASE-Result: 10--8.132900-10.000000 X-TMASE-MatchedRID: 90G6ca/P0SOe/kF8Pup4HKzGfgakLdjawTlc9CcHMZerwqxtE531VIPc XuILVCbak2rNDhoFVtmq5anvU2i8LHk5VN4DJHKIh2VzUlo4HVM2LwvzxRX0gEA6+2WeJ60F8/e HChOsjzqBx0ShwZLio0dHbFW6uX0ZNYwYTEoASsF1e7Xbb6Im2pRy1HDTPOXaT2ewVK0RXfKjxY yRBa/qJcFwgTvxipFajoczmuoPCq22ULtTyMM9Wtota5iZKohuhGR862+bRwKSXfyNyvbxKno5M nkQalgJ X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-7.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-7.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 3/7] syscalls/swapon03: use tst_max_swapfiles() and GET_USED_SWAPFILES() api X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yang Xu via ltp From: "Yang Xu \\(Fujitsu\\)" Reply-To: Yang Xu Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Yang Xu --- testcases/kernel/syscalls/swapon/swapon03.c | 43 +++++---------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c index 05fe2045f..e27d954a1 100644 --- a/testcases/kernel/syscalls/swapon/swapon03.c +++ b/testcases/kernel/syscalls/swapon/swapon03.c @@ -19,7 +19,6 @@ #include "tst_test.h" #include "lapi/syscalls.h" -#include "swaponoff.h" #include "libswap.h" #define MNTPOINT "mntpoint" @@ -105,47 +104,20 @@ static void verify_swapon(void) static int setup_swap(void) { pid_t pid; - int j, fd; int status; + int j, max_swapfiles, used_swapfiles; int res = 0; char filename[FILENAME_MAX]; - char buf[BUFSIZ + 1]; - - /* Find out how many swapfiles (1 line per entry) already exist */ - swapfiles = 0; if (seteuid(0) < 0) tst_brk(TFAIL | TERRNO, "Failed to call seteuid"); - /* This includes the first (header) line */ - if ((fd = open("/proc/swaps", O_RDONLY)) == -1) { - tst_brk(TFAIL | TERRNO, - "Failed to find out existing number of swap files"); - } - do { - char *p = buf; - res = read(fd, buf, BUFSIZ); - if (res < 0) { - tst_brk(TFAIL | TERRNO, - "Failed to find out existing number of swap files"); - } - buf[res] = '\0'; - while ((p = strchr(p, '\n'))) { - p++; - swapfiles++; - } - } while (BUFSIZ <= res); - close(fd); - if (swapfiles) - swapfiles--; /* don't count the /proc/swaps header */ - - if (swapfiles < 0) - tst_brk(TFAIL, "Failed to find existing number of swapfiles"); - /* Determine how many more files are to be created */ - swapfiles = MAX_SWAPFILES - swapfiles; - if (swapfiles > MAX_SWAPFILES) - swapfiles = MAX_SWAPFILES; + max_swapfiles = tst_max_swapfiles(); + used_swapfiles = tst_count_swaps(); + swapfiles = max_swapfiles - used_swapfiles; + if (swapfiles > max_swapfiles) + swapfiles = max_swapfiles; pid = SAFE_FORK(); if (pid == 0) { /*create and turn on remaining swapfiles */ @@ -260,6 +232,9 @@ static void setup(void) if (access("/proc/swaps", F_OK)) tst_brk(TCONF, "swap not supported by kernel"); + if (tst_fs_type(".") == TST_TMPFS_MAGIC) + tst_brk(TCONF, "swap not supported on tmpfs"); + is_swap_supported(TEST_FILE); } From patchwork Thu Feb 8 10:05:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang Xu \\(Fujitsu\\)" X-Patchwork-Id: 1896523 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lists.linux.it header.i=@lists.linux.it header.a=rsa-sha256 header.s=picard header.b=qPphIke9; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=CCxiGLHM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TVt2B46sxz23hn for ; Thu, 8 Feb 2024 21:07:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it; i=@lists.linux.it; q=dns/txt; s=picard; t=1707386832; h=to : date : message-id : in-reply-to : references : mime-version : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : from : reply-to : content-type : content-transfer-encoding : sender : from; bh=jjAzDFe4MAhERhniI+p+xy6XnLc7QgOR9jSycMK9CUE=; b=qPphIke9FjDHNKNpkSkKgGfx+KYRwaBdPRE0JLMEHDADYehW/P2aeOgiLJQ9JRRJEoupi 7vb9DMT/EVDQQLGi9e7r6OU43kHkPC6d1KO+BJdMJGfEv1zc9eGUfl14iLfBxlQ93999f5p SZDWYCJuTsXBdrSb6nbVfm7n7uzhsuE= Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 73D4D3CC4AD for ; Thu, 8 Feb 2024 11:07:12 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 1D2623C5AC4 for ; Thu, 8 Feb 2024 11:05:48 +0100 (CET) Authentication-Results: in-6.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=fujitsu.com (client-ip=207.54.90.49; helo=esa3.hc1455-7.c3s2.iphmx.com; envelope-from=xuyang2018.jy@fujitsu.com; receiver=lists.linux.it) Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 7E1101400F34 for ; Thu, 8 Feb 2024 11:05:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1707386747; x=1738922747; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z1xHRP2Ek7YJeSS1pq7YTvaQCanZi7//foGZS2wgUd8=; b=CCxiGLHMZuIBb/COfGlGIdLimXPdPK6t5VGL1WHV36kjWaFbuNbPkg7J QcdZbZkobB+hlbLGaK4DkzQ3WK7iQyLaOa+XbwA7I9+ewMayNPRBwpeuq 4n2qjc7e666bblaGClooBKjgNyc/KnOAHGXjAt6lH8KIFYwLL/u0ja++f bYgV1SgiSN5pjwoJT0SfFtXwwLtonxlSJPFAwsTcKAdNaLVZxCdFp+Bse 7aAvlCTS5FvAmcn3m3iDIjJfpLAC7KirvcxxAP2utlTZqbN0Yo1RHO9EU ukBPndKHNjqbm8lxmR4dKF/u/sOZiyMM5iutWbH83FyKjTjPBZx81zIYo g==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="148804475" X-IronPort-AV: E=Sophos;i="6.05,253,1701097200"; d="scan'208";a="148804475" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 19:05:45 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id B07FB1625FF for ; Thu, 8 Feb 2024 19:05:42 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 0367EF31B1 for ; Thu, 8 Feb 2024 19:05:42 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 8025E20097CDF for ; Thu, 8 Feb 2024 19:05:39 +0900 (JST) Received: from rhel93GA.g08.fujitsu.local (unknown [10.167.221.71]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 371441A009A; Thu, 8 Feb 2024 18:05:39 +0800 (CST) To: ltp@lists.linux.it Date: Thu, 8 Feb 2024 05:05:14 -0500 Message-Id: <20240208100517.1974-4-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> References: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28178.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28178.004 X-TMASE-Result: 10--9.963700-10.000000 X-TMASE-MatchedRID: JBufqG2vPnQIGXYTUlAoHxIRh9wkXSlF9LMB0hXFSeikob0Y35+HFI3c eRXYSJoDIvrftAIhWmLy9zcRSkKatXwzxAv8kID0Ss47mbT7SARcsgu/IQFPzpsoi2XrUn/J8m+ hzBStansUGm4zriL0oQtuKBGekqUpI/NGWt0UYPCI7sC4haewV/n9viGv+yGih2qTfLe5tYivgh rXlvlCEClDYiLWw5+B X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-6.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-6.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 4/7] swaponoff.h: Remove useless header X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yang Xu via ltp From: "Yang Xu \\(Fujitsu\\)" Reply-To: Yang Xu Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Since we have use tst_max_swapfiles() api in swapon03.c, so this header is useless and can be removed safely. Signed-off-by: Yang Xu --- testcases/kernel/syscalls/swapon/swaponoff.h | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 testcases/kernel/syscalls/swapon/swaponoff.h diff --git a/testcases/kernel/syscalls/swapon/swaponoff.h b/testcases/kernel/syscalls/swapon/swaponoff.h deleted file mode 100644 index 900761bda..000000000 --- a/testcases/kernel/syscalls/swapon/swaponoff.h +++ /dev/null @@ -1,8 +0,0 @@ - -#ifndef __SWAP_ON_OFF_H_ -#define __SWAP_ON_OFF_H_ - -#include -#define MAX_SWAPFILES 30 - -#endif From patchwork Thu Feb 8 10:05:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang Xu \\(Fujitsu\\)" X-Patchwork-Id: 1896522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lists.linux.it header.i=@lists.linux.it header.a=rsa-sha256 header.s=picard header.b=aJ0WsqOW; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=k/AHUSYh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TVt1k08WXz23hn for ; Thu, 8 Feb 2024 21:06:50 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it; i=@lists.linux.it; q=dns/txt; s=picard; t=1707386807; h=to : date : message-id : in-reply-to : references : mime-version : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : from : reply-to : content-type : content-transfer-encoding : sender : from; bh=gIeEvi2HwuF4Erjxf06qAepdxlKzo2x9xTB64AnuRPo=; b=aJ0WsqOWNnmksn/DRiRCL8e9v6WVjCtPs04Wlb2dQX5WQkocXy7m2Ad+lLoo4X+QkY8QM rLTFTwYRIHt8hi6bfir0W7Set9MzvJcNOsAi40g6hE5IA6gT2FpN4Fyn/GqNzisVBbtMRhO 2kofpybGYudPNNYrqcvYbLo7EvVxTIU= Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C295D3CC4B5 for ; Thu, 8 Feb 2024 11:06:47 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 573C43CDEA3 for ; Thu, 8 Feb 2024 11:05:46 +0100 (CET) Authentication-Results: in-5.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=fujitsu.com (client-ip=68.232.139.117; helo=esa4.hc1455-7.c3s2.iphmx.com; envelope-from=xuyang2018.jy@fujitsu.com; receiver=lists.linux.it) Received: from esa4.hc1455-7.c3s2.iphmx.com (esa4.hc1455-7.c3s2.iphmx.com [68.232.139.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id A47B66126EF for ; Thu, 8 Feb 2024 11:05:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1707386745; x=1738922745; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CQ/gqH2/WQGfgWR5xnkmHzNwd9etVFLbZglXhaGPf4M=; b=k/AHUSYhrHYrk3dEBMDhCk9hxC6aQTbv1DRJ0mMav4Z6exBLaJo8+wap 4AehiV4I7/uV3/LfXOeRKcBdlzXAmRD0FKCLum6bRncGcN1IUHqoelrAy atENcM0S7AlRinSyVZxWXBNscD4zNdmfkwziQaOEs4SaAT5vJlO42+uez WUz+02pAjoIJ2TxkYzEnzGWKAERUjElGwHN3A/JAhB8oxqV/g7VE6z6z8 ICD/lqYp4uWyP6KJfewGiz7YjFn/A4I+iSVD/W1Y3CO/BCF+Rh23lmcTL Bm4pKB14uVLwV4mDnZ4QQu0mIFwoLlAkZNyUdQdIb5KvfEs6VE5jsDlvL A==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="149090809" X-IronPort-AV: E=Sophos;i="6.05,253,1701097200"; d="scan'208";a="149090809" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 19:05:43 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id B721E2328EB for ; Thu, 8 Feb 2024 19:05:41 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id E667919B97B for ; Thu, 8 Feb 2024 19:05:40 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 7E33A82D4E for ; Thu, 8 Feb 2024 19:05:40 +0900 (JST) Received: from rhel93GA.g08.fujitsu.local (unknown [10.167.221.71]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 206151A009A; Thu, 8 Feb 2024 18:05:40 +0800 (CST) To: ltp@lists.linux.it Date: Thu, 8 Feb 2024 05:05:15 -0500 Message-Id: <20240208100517.1974-5-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> References: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28178.003 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28178.003 X-TMASE-Result: 10--10.747900-10.000000 X-TMASE-MatchedRID: DUlKOBWbo0l+fOZykHM6uwQ6EfMOwvTm205HfQzgPdFUjspoiX02Fz13 GoPFA1HFIvrftAIhWmLy9zcRSkKatcOJmY4XRXkVQQp1SVSsqYAWUg/hm489yLgbJOZ434Bsi8x T7YmZq8v8MuFbVBBITpu74XJZgEpKHxPMjOKY7A+Wlioo2ZbGwdmzcdRxL+xwKrauXd3MZDVtYe InNJpWkTqia33fkvvrqPqgX8slUNMKeU6HPw+SKd5TJ+G7pHTx X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-5.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 5/7] swapon/Makefile: Remove useless section for MAX_SWAPFILES X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yang Xu via ltp From: "Yang Xu \\(Fujitsu\\)" Reply-To: Yang Xu Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" It seems this section doesn't affect anything, btw it is useless, so remove it. Reviewed-by: Cyril Hrubis Signed-off-by: Yang Xu --- testcases/kernel/syscalls/swapon/Makefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/testcases/kernel/syscalls/swapon/Makefile b/testcases/kernel/syscalls/swapon/Makefile index 53c795090..6954112a8 100644 --- a/testcases/kernel/syscalls/swapon/Makefile +++ b/testcases/kernel/syscalls/swapon/Makefile @@ -1,11 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (c) International Business Machines Corp., 2001 -NEEDSPECIAL := $(shell echo MAX_SWAPFILES | $(CC) -E -xc -include linux/swap.h 2>/dev/null - | tail -n 1 | grep 32; echo $?) -ifneq ($(strip $(NEEDSPECIAL)),) -export CFLAGS += -DOLDER_DISTRO_RELEASE -endif - top_srcdir ?= ../../../.. LTPLIBS = ltpswap From patchwork Thu Feb 8 10:05:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang Xu \\(Fujitsu\\)" X-Patchwork-Id: 1896524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lists.linux.it header.i=@lists.linux.it header.a=rsa-sha256 header.s=picard header.b=HQlDISsD; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=NXIAdPtq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TVt2f0KXQz23hn for ; Thu, 8 Feb 2024 21:07:38 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it; i=@lists.linux.it; q=dns/txt; s=picard; t=1707386855; h=to : date : message-id : in-reply-to : references : mime-version : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : from : reply-to : content-type : content-transfer-encoding : sender : from; bh=A+6dY6z9tO7zNdg1wdCUMpoldNxnlBo9NFjnS7HKH94=; b=HQlDISsD4+BxvKenKZrfXepAx/xVYKs6AtKTzNjqZHjSeaKv2D8tO43T28g4HJXrxfrb7 fZf3Vhn1RGUHwMVkUCCYgP7RrPUxBxct3B2QZeqev6VL1qfXJm2BSdlDqHQ1plhTTrjzdR4 KNqIBIY3ZcinFVnP6wdb+gey1tyrOvQ= Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E6E4B3CC4BC for ; Thu, 8 Feb 2024 11:07:35 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id D12F53CC4AD for ; Thu, 8 Feb 2024 11:05:48 +0100 (CET) Authentication-Results: in-6.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=fujitsu.com (client-ip=207.54.90.49; helo=esa3.hc1455-7.c3s2.iphmx.com; envelope-from=xuyang2018.jy@fujitsu.com; receiver=lists.linux.it) Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id E67F314010D9 for ; Thu, 8 Feb 2024 11:05:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1707386748; x=1738922748; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S5jFYD5bpraOwgClKCUwt17CtqPjJ2UePdoBicKaHhM=; b=NXIAdPtq9MWtWZxBLGeCJhPLbBefeQJdE7ZtcviKD4L0K1SHsIijsf2u Ulq+g7bgkhhbllQcdFbGqCzRQfdjoPpo6QxrhVuSPDUEN4YpgM6sNADcv lPhd3BQyDEhs0npZifJriEdI4lAji11uXhQH0Sz1XQMLVVNoD64uj7C0D MzkHM/UhkjLCXp1Hn8MkY92p8rXPukkHgjA4I8PWkuV22dT5IjIWMnQXG IxB+KF/bNGzyAb3XJg1+UqXf5pTchrgJngLh1ma0tG6CpQGCiQ3sftV5k vmIaL3mMWV+XSYpJmyvCTjw3B4MmWwQPygJRVkoJMn2kJ9jNkADQHh5lT A==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="148804474" X-IronPort-AV: E=Sophos;i="6.05,253,1701097200"; d="scan'208";a="148804474" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 19:05:45 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id A88FE287624 for ; Thu, 8 Feb 2024 19:05:42 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id D911FBF4A4 for ; Thu, 8 Feb 2024 19:05:41 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 76F1A41043 for ; Thu, 8 Feb 2024 19:05:41 +0900 (JST) Received: from rhel93GA.g08.fujitsu.local (unknown [10.167.221.71]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 293BA1A009A; Thu, 8 Feb 2024 18:05:41 +0800 (CST) To: ltp@lists.linux.it Date: Thu, 8 Feb 2024 05:05:16 -0500 Message-Id: <20240208100517.1974-6-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> References: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28178.003 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28178.003 X-TMASE-Result: 10--13.443200-10.000000 X-TMASE-MatchedRID: ivopYYUv4wOoXGwWsKbNNMQ4mpKyfkqZqf/efKFN1nAsNj/xIgdFOz13 GoPFA1HFIvrftAIhWmLy9zcRSkKatYRiOzyn0C74DnkURiAlfT0Ea8g1x8eqF8+FtP9CIg3lGJ0 UP0AzEBXF0OnGYU+EGEyVB8hCiPpVv7DNTciZY+u/QNwZdfw3FVf0dYIWn7J33unRG7yMq8Wsw1 6ankSpXeLuuo8wVu5nyHMs+sHfluzHOkf2+KMD/BIRh9wkXSlFe9J6VkwneFZp2y18eTT/bUwSv UpzAIpVruaWnsz0aFiAMuqetGVetnyef22ep6XY4kYXbobxJbLyU/oX+tpNmPoLEnltozQnbTWF 2en2y4gIi8h9veOWEFmDDZo4qdDBtDApshcJLEi+68HqACCvKA== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-6.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-6.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 6/7] syscalls/swapon03: Simply this case X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yang Xu via ltp From: "Yang Xu \\(Fujitsu\\)" Reply-To: Yang Xu Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" By moving swapfile create stage from verify_swaopon and test EPERM error more accurate. Also use glibc wrapper by using swapon/swapoff instead of call syscall number directly because glibc/musl/binoic also support them since long time ago. Signed-off-by: Yang Xu --- testcases/kernel/syscalls/swapon/swapon03.c | 170 +++++--------------- 1 file changed, 43 insertions(+), 127 deletions(-) diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c index e27d954a1..5ba7971e7 100644 --- a/testcases/kernel/syscalls/swapon/swapon03.c +++ b/testcases/kernel/syscalls/swapon/swapon03.c @@ -16,7 +16,7 @@ #include #include #include - +#include #include "tst_test.h" #include "lapi/syscalls.h" #include "libswap.h" @@ -24,89 +24,13 @@ #define MNTPOINT "mntpoint" #define TEST_FILE MNTPOINT"/testswap" -static int setup_swap(void); -static int clean_swap(void); -static int check_and_swapoff(const char *filename); - static int swapfiles; -int testfiles = 3; -static struct swap_testfile_t { - char *filename; -} swap_testfiles[] = { - {"firstswapfile"}, - {"secondswapfile"}, - {"thirdswapfile"} -}; - -int expected_errno = EPERM; - -static void verify_swapon(void) -{ - if (setup_swap() < 0) { - clean_swap(); - tst_brk(TBROK, "Setup failed, quitting the test"); - } - - TEST(tst_syscall(__NR_swapon, swap_testfiles[0].filename, 0)); - - if ((TST_RET == -1) && (TST_ERR == expected_errno)) { - tst_res(TPASS, "swapon(2) got expected failure (%d),", - expected_errno); - } else if (TST_RET < 0) { - tst_res(TFAIL | TTERRNO, - "swapon(2) failed to produce expected error " - "(%d). System reboot recommended.", - expected_errno); - } else { - /* - * Probably the system supports MAX_SWAPFILES > 30, let's try with - * MAX_SWAPFILES == 32. Call swapon sys call once again for 32 - * now we can't receive an error. - */ - TEST(tst_syscall(__NR_swapon, swap_testfiles[1].filename, 0)); - - /* Check return code (now we're expecting success) */ - if (TST_RET < 0) { - tst_res(TFAIL | TTERRNO, - "swapon(2) got an unexpected failure"); - } else { - /* - * Call swapon sys call once again for 33 now we have to receive an error. - */ - TEST(tst_syscall(__NR_swapon, swap_testfiles[2].filename, 0)); - - /* Check return code (should be an error) */ - if ((TST_RET == -1) && (TST_ERR == expected_errno)) { - tst_res(TPASS, - "swapon(2) got expected failure;" - " Got errno = %d, probably your" - " MAX_SWAPFILES is 32", - expected_errno); - } else { - tst_res(TFAIL, - "swapon(2) failed to produce" - " expected error: %d, got %s." - " System reboot after execution of LTP" - " test suite is recommended.", - expected_errno, strerror(TST_ERR)); - } - } - } - - if (clean_swap() < 0) - tst_brk(TBROK, "Cleanup failed, quitting the test"); -} - -/* - * Create 33 and activate 30 swapfiles. - */ static int setup_swap(void) { pid_t pid; int status; int j, max_swapfiles, used_swapfiles; - int res = 0; char filename[FILENAME_MAX]; if (seteuid(0) < 0) @@ -134,16 +58,7 @@ static int setup_swap(void) make_swapfile(filename, 10, 0); /* turn on the swap file */ - res = tst_syscall(__NR_swapon, filename, 0); - if (res != 0) { - if (errno == EPERM) { - printf("Successfully created %d swapfiles\n", j); - break; - } else { - printf("Failed to create swapfile: %s\n", filename); - exit(1); - } - } + TST_EXP_PASS_SILENT(swapon(filename, 0)); } exit(0); } else @@ -152,13 +67,41 @@ static int setup_swap(void) if (WEXITSTATUS(status)) tst_brk(TFAIL, "Failed to setup swaps"); - /* Create all needed extra swapfiles for testing */ - for (j = 0; j < testfiles; j++) - make_swapfile(swap_testfiles[j].filename, 10, 0); + tst_res(TINFO, "Successfully created %d swapfiles", swapfiles); + make_swapfile(TEST_FILE, 10, 0); return 0; } +/* + * Check if the file is at /proc/swaps and remove it giving swapoff + */ +static int check_and_swapoff(const char *filename) +{ + char cmd_buffer[256]; + int rc = -1; + + if (snprintf(cmd_buffer, sizeof(cmd_buffer), + "grep -q '%s.*file' /proc/swaps", filename) < 0) { + tst_res(TWARN, "sprintf() failed to create the command string"); + } else { + rc = 0; + if (system(cmd_buffer) == 0) { + /* now we need to swapoff the file */ + if (swapoff(filename) != 0) { + tst_res(TWARN, "Failed to turn off swap " + "file. system reboot after " + "execution of LTP test suite " + "is recommended"); + rc = -1; + } + + } + } + + return rc; +} + /* * Turn off all swapfiles previously turned on */ @@ -182,49 +125,17 @@ static int clean_swap(void) } } - for (j = 0; j < testfiles; j++) { - if (check_and_swapoff(swap_testfiles[j].filename) != 0) { - tst_res(TWARN, "Failed to turn off swap file %s.", - swap_testfiles[j].filename); - return -1; - } + if (check_and_swapoff("testfile") != 0) { + tst_res(TWARN, "Failed to turn off swap file testfile"); + return -1; } return 0; } -/* - * Check if the file is at /proc/swaps and remove it giving swapoff - */ -static int check_and_swapoff(const char *filename) +static void verify_swapon(void) { - char cmd_buffer[256]; - int rc = -1; - - if (snprintf(cmd_buffer, sizeof(cmd_buffer), - "grep -q '%s.*file' /proc/swaps", filename) < 0) { - tst_res(TWARN, "sprintf() failed to create the command string"); - } else { - - rc = 0; - - if (system(cmd_buffer) == 0) { - - /* now we need to swapoff the file */ - if (tst_syscall(__NR_swapoff, filename) != 0) { - - tst_res(TWARN, "Failed to turn off swap " - "file. system reboot after " - "execution of LTP test suite " - "is recommended"); - rc = -1; - - } - - } - } - - return rc; + TST_EXP_FAIL(swapon(TEST_FILE, 0), EPERM, "swapon(%s, 0)", TEST_FILE); } static void setup(void) @@ -236,6 +147,11 @@ static void setup(void) tst_brk(TCONF, "swap not supported on tmpfs"); is_swap_supported(TEST_FILE); + + if (setup_swap() < 0) { + clean_swap(); + tst_brk(TBROK, "Setup failed, quitting the test"); + } } static void cleanup(void) From patchwork Thu Feb 8 10:05:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang Xu \\(Fujitsu\\)" X-Patchwork-Id: 1896525 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lists.linux.it header.i=@lists.linux.it header.a=rsa-sha256 header.s=picard header.b=DOcrA3cY; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=cvX8yE3z; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TVt3D0dsTz23hn for ; Thu, 8 Feb 2024 21:08:08 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it; i=@lists.linux.it; q=dns/txt; s=picard; t=1707386886; h=to : date : message-id : in-reply-to : references : mime-version : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : from : reply-to : content-type : content-transfer-encoding : sender : from; bh=qTRnZPsnkt8OTyaWuRufUxNdnieeF38TUX5yIQfq6kw=; b=DOcrA3cYPXTWmltIiY8ZUnmb17dEbtGWiRZk4KVzp0fix4g2P/cB+e4Mj4J5zxvDzHoFX q9Ud9T4A6NqqV98IxTuVtG5uFhAThsO190yT2OzX5y4eX0aZ0WmZxRpXmAja6Ab0UBDYkSt JoKz9JuZbFMrpvQktcdGeJPOm19SPgs= Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 22A613C5AC4 for ; Thu, 8 Feb 2024 11:08:06 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 1340B3CDEA8 for ; Thu, 8 Feb 2024 11:05:51 +0100 (CET) Authentication-Results: in-2.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=fujitsu.com (client-ip=139.138.36.223; helo=esa9.hc1455-7.c3s2.iphmx.com; envelope-from=xuyang2018.jy@fujitsu.com; receiver=lists.linux.it) Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id E7CB2631D68 for ; Thu, 8 Feb 2024 11:05:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1707386747; x=1738922747; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a7MuluFDfHG6tWmxwNPQhdi6VZiU+qa17JShBK4DvWE=; b=cvX8yE3zAcdOjI7Zzr3P7kpL7RSk54F/NMGM6E95RnUF3zgiLkmMMwTC kdFWKe4m8Ph7UmrO5Zn9DFeGlCOJDyv+v5FrRiwfFxcRjRhJMCrFo+siy M7AvNDneiX7doYRuqKeITse9HnGKRQGnzTLr0E+7csNEXopsyksydv8Ze TkCZrLwsIWbxQ8x9RrpTHEptiK8jYj5x1t10hmMfUJ4lfRTmwLQJzSwOf tGor6FRI1cnkGasOiujzzwnveLAAWTc9eNWNM/pTbolqCN9voFxRuXGF+ oPmmOQwLVSBTwWlBcpdSpRJnYIljAsK/f9nI5kUjItsSTb6NMuFBAIrIg g==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="137258281" X-IronPort-AV: E=Sophos;i="6.05,253,1701097200"; d="scan'208";a="137258281" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 19:05:45 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id A88AE1F4276 for ; Thu, 8 Feb 2024 19:05:43 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id F2D99D561D for ; Thu, 8 Feb 2024 19:05:42 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 85A1B20097CDF for ; Thu, 8 Feb 2024 19:05:42 +0900 (JST) Received: from rhel93GA.g08.fujitsu.local (unknown [10.167.221.71]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 3C16E1A009A; Thu, 8 Feb 2024 18:05:42 +0800 (CST) To: ltp@lists.linux.it Date: Thu, 8 Feb 2024 05:05:17 -0500 Message-Id: <20240208100517.1974-7-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> References: <20240208100517.1974-1-xuyang2018.jy@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28178.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28178.004 X-TMASE-Result: 10--6.494500-10.000000 X-TMASE-MatchedRID: RtHHqK+8YWP5S+IvXI7mDQA+Y0oNaxbQ1QQ6Jx/fflbEWhdVdXNnv4nO /I/i7S2AIvrftAIhWmLy9zcRSkKatcdu/gFP87q2utvHF25zoU+B3MgXjyY30GA+B6CBXAIWGQs bWiaS+mxzzWLzuR3HAoAy6p60ZV62fJ5/bZ6npdg7AFczfjr/7CPdgxmK9T6WI/DQJ89r5px7as ZtGCaty7HeH/tqOv22BQf5huPIT9E= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-2.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 7/7] Add fallback for RHEL9 X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yang Xu via ltp From: "Yang Xu \\(Fujitsu\\)" Reply-To: Yang Xu Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Since device number patch and pte number patch have been backported into RHEL9, we should add fallback for this distro. Signed-off-by: Yang Xu --- libs/libltpswap/libswap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/libltpswap/libswap.c b/libs/libltpswap/libswap.c index fa0d42543..547750948 100644 --- a/libs/libltpswap/libswap.c +++ b/libs/libltpswap/libswap.c @@ -17,6 +17,7 @@ #include "libswap.h" #include "lapi/syscalls.h" #include "tst_kconfig.h" +#include "tst_kvercmp.h" #include "tst_safe_stdio.h" static const char *const swap_supported_fs[] = { @@ -231,6 +232,11 @@ int tst_max_swapfiles(void) struct tst_kconfig_var memory_kconfig = TST_KCONFIG_INIT("CONFIG_MEMORY_FAILURE"); struct tst_kconfig_var device_kconfig = TST_KCONFIG_INIT("CONFIG_DEVICE_PRIVATE"); struct tst_kconfig_var marker_kconfig = TST_KCONFIG_INIT("CONFIG_PTE_MARKER"); + struct tst_kern_exv kvers[] = { + /* RHEL9 kernel has patch 6c287605f and 679d10331 since 5.14.0-179 */ + { "RHEL9", "5.14.0-179" }, + { NULL, NULL}, + }; tst_kconfig_read(&migration_kconfig, 1); tst_kconfig_read(&memory_kconfig, 1); @@ -238,7 +244,7 @@ int tst_max_swapfiles(void) tst_kconfig_read(&marker_kconfig, 1); if (migration_kconfig.choice == 'y') { - if (tst_kvercmp(5, 19, 0) < 0) + if (tst_kvercmp2(5, 19, 0, kvers) < 0) swp_migration_num = 2; else swp_migration_num = 3; @@ -255,7 +261,7 @@ int tst_max_swapfiles(void) } if (marker_kconfig.choice == 'y') { - if (tst_kvercmp(5, 19, 0) >= 0) + if (tst_kvercmp2(5, 19, 0, kvers) >= 0) swp_pte_marker_num = 1; }