From patchwork Thu Mar 3 14:50:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1600377 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=Iiy7edhC; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vrPvX+FS; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8Yl16hCVz9sG3 for ; Fri, 4 Mar 2022 01:48:29 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D6A3A3CA368 for ; Thu, 3 Mar 2022 15:48:26 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 2166F3CA1EC for ; Thu, 3 Mar 2022 15:48:14 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id B110C1A0043E for ; Thu, 3 Mar 2022 15:48:13 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 05E90210FA for ; Thu, 3 Mar 2022 14:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646318893; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J7W372LUUpsgzwy1st0FYdJVRMyZonN2qTmJyI24GLc=; b=Iiy7edhC6lsPe7fxbEsOLf5go4I383a/wscyQk5vWijsNfJHwZ4L0ItTiJ1wpxp/XhhTsn 3yJjduq/lOwmM9+ChvZaEXgOoYDWVVtmkiptQxXZTatXb55VqjIMsqXmDc2aw8b3Kf6PwK ukIQ+1rU37xtuIM3jUZyOmtbzfnEavE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646318893; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J7W372LUUpsgzwy1st0FYdJVRMyZonN2qTmJyI24GLc=; b=vrPvX+FSyP8bq3mxt4A1wo4cO16FUnSRRevvs6XN29sLSy5D3xmHdaDjJNi7Aj/Ziq0xtP 53aMH5DpbvOfpvDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E47C613AD9 for ; Thu, 3 Mar 2022 14:48:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Z4HrNSzVIGL0AgAAMHmgww (envelope-from ) for ; Thu, 03 Mar 2022 14:48:12 +0000 From: Cyril Hrubis To: ltp@lists.linux.it Date: Thu, 3 Mar 2022 15:50:26 +0100 Message-Id: <20220303145032.21493-2-chrubis@suse.cz> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220303145032.21493-1-chrubis@suse.cz> References: <20220303145032.21493-1-chrubis@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH 1/7] ksm06: Move option parsing into the setup() 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Cyril Hrubis Reviewed-by: Richard Palethorpe --- testcases/kernel/mem/ksm/ksm06.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c index c5f219c37..379236f1f 100644 --- a/testcases/kernel/mem/ksm/ksm06.c +++ b/testcases/kernel/mem/ksm/ksm06.c @@ -42,17 +42,12 @@ static int run = -1; static int sleep_millisecs = -1; static int merge_across_nodes = -1; -static unsigned long nr_pages; +static unsigned long nr_pages = 100; static char *n_opt; static void test_ksm(void) { - if (n_opt) - nr_pages = SAFE_STRTOUL(n_opt, 0, ULONG_MAX); - else - nr_pages = 100; - test_ksm_merge_across_nodes(nr_pages); } @@ -64,6 +59,9 @@ static void setup(void) if (!is_numa(NULL, NH_MEMS, 2)) tst_brk(TCONF, "The case needs a NUMA system."); + if (n_opt) + nr_pages = SAFE_STRTOUL(n_opt, 0, ULONG_MAX); + /* save the current value */ SAFE_FILE_SCANF(PATH_KSM "run", "%d", &run); SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes", From patchwork Thu Mar 3 14:50:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1600378 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=o6qxfDFy; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Myev8zF/; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8YlD6Vvyz9sG3 for ; Fri, 4 Mar 2022 01:48:40 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 675BC3CA326 for ; Thu, 3 Mar 2022 15:48:37 +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 RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 4B6F23CA1EC for ; Thu, 3 Mar 2022 15:48:14 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id DD0E8600D75 for ; Thu, 3 Mar 2022 15:48:13 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8C339218A9 for ; Thu, 3 Mar 2022 14:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646318893; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+1s0MhTI8ulBduidA8tCJb8hP+3r3IPLXGx16R1zNwo=; b=o6qxfDFyVgOuj78O1SehciS1a3F4/3T8Z7YUsEfhoYABFfVeIyBLkj7UuSwIn/TngyZN30 m6LSb6zf5i6t4CCK8v2ufDjO1/aIRNW6nBhcq6t1s8jrDUVsa5GCBYsvfc1z71A70H/yFI ZOTTSBrxpgtjfzo+hPzveQODFZCDx3w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646318893; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+1s0MhTI8ulBduidA8tCJb8hP+3r3IPLXGx16R1zNwo=; b=Myev8zF/jeDxc16EAAIHtYBYG3xsFJTdIIY9IbSTop40qW3o8jtVb7IeIAuo28V85akO6k JuegwG2slWRAoIDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7524E13AD9 for ; Thu, 3 Mar 2022 14:48:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AR7jGi3VIGL3AgAAMHmgww (envelope-from ) for ; Thu, 03 Mar 2022 14:48:13 +0000 From: Cyril Hrubis To: ltp@lists.linux.it Date: Thu, 3 Mar 2022 15:50:27 +0100 Message-Id: <20220303145032.21493-3-chrubis@suse.cz> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220303145032.21493-1-chrubis@suse.cz> References: <20220303145032.21493-1-chrubis@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH 2/7] mem/lib: Export group_check() as ksm_group_check() 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This is preparing for the move of the code from library to the ksm06. Signed-off-by: Cyril Hrubis Reviewed-by: Richard Palethorpe --- testcases/kernel/mem/include/mem.h | 2 ++ testcases/kernel/mem/lib/mem.c | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h index f1cba5fcb..776809113 100644 --- a/testcases/kernel/mem/include/mem.h +++ b/testcases/kernel/mem/include/mem.h @@ -50,6 +50,8 @@ void testoom(int mempolicy, int lite, int retcode, int allow_sigkill); void create_same_memory(int size, int num, int unit); void test_ksm_merge_across_nodes(unsigned long nr_pages); +void ksm_group_check(int run, int pg_shared, int pg_sharing, int pg_volatile, + int pg_unshared, int sleep_msecs, int pages_to_scan); /* THP */ diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index ee9fc85b6..102fc5665 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -271,9 +271,9 @@ static void final_group_check(int run, int pages_shared, int pages_sharing, check("pages_to_scan", pages_to_scan); } -static void group_check(int run, int pages_shared, int pages_sharing, - int pages_volatile, int pages_unshared, - int sleep_millisecs, int pages_to_scan) +void ksm_group_check(int run, int pages_shared, int pages_sharing, + int pages_volatile, int pages_unshared, + int sleep_millisecs, int pages_to_scan) { if (run != 1) { tst_res(TFAIL, "group_check run is not 1, %d.", run); @@ -489,19 +489,19 @@ void create_same_memory(int size, int num, int unit) resume_ksm_children(child, num); stop_ksm_children(child, num); - group_check(1, 2, size * num * pages - 2, 0, 0, 0, size * pages * num); + ksm_group_check(1, 2, size * num * pages - 2, 0, 0, 0, size * pages * num); resume_ksm_children(child, num); stop_ksm_children(child, num); - group_check(1, 3, size * num * pages - 3, 0, 0, 0, size * pages * num); + ksm_group_check(1, 3, size * num * pages - 3, 0, 0, 0, size * pages * num); resume_ksm_children(child, num); stop_ksm_children(child, num); - group_check(1, 1, size * num * pages - 1, 0, 0, 0, size * pages * num); + ksm_group_check(1, 1, size * num * pages - 1, 0, 0, 0, size * pages * num); resume_ksm_children(child, num); stop_ksm_children(child, num); - group_check(1, 1, size * num * pages - 2, 0, 1, 0, size * pages * num); + ksm_group_check(1, 1, size * num * pages - 2, 0, 1, 0, size * pages * num); tst_res(TINFO, "KSM unmerging..."); SAFE_FILE_PRINTF(PATH_KSM "run", "2"); @@ -586,15 +586,15 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages) tst_res(TINFO, "Start to test KSM with merge_across_nodes=1"); SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1"); SAFE_FILE_PRINTF(PATH_KSM "run", "1"); - group_check(1, 1, nr_pages * num_nodes - 1, 0, 0, 0, - nr_pages * num_nodes); + ksm_group_check(1, 1, nr_pages * num_nodes - 1, 0, 0, 0, + nr_pages * num_nodes); SAFE_FILE_PRINTF(PATH_KSM "run", "2"); tst_res(TINFO, "Start to test KSM with merge_across_nodes=0"); SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "0"); SAFE_FILE_PRINTF(PATH_KSM "run", "1"); - group_check(1, num_nodes, nr_pages * num_nodes - num_nodes, - 0, 0, 0, nr_pages * num_nodes); + ksm_group_check(1, num_nodes, nr_pages * num_nodes - num_nodes, + 0, 0, 0, nr_pages * num_nodes); SAFE_FILE_PRINTF(PATH_KSM "run", "2"); From patchwork Thu Mar 3 14:50:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1600379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=Ml8ihPHa; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=zIzUC9J6; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8YlQ6y5cz9sG3 for ; Fri, 4 Mar 2022 01:48:50 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id BF8A53CA36F for ; Thu, 3 Mar 2022 15:48:47 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 002193CA1EC for ; Thu, 3 Mar 2022 15:48:14 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 75E6E1A0079E for ; Thu, 3 Mar 2022 15:48:14 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 169951F384 for ; Thu, 3 Mar 2022 14:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646318894; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WEpl2zxA/wMor/6h90eumJW1A6bcL7xQObRg2Q3NI8M=; b=Ml8ihPHa5cZq+yDCmzOyWXpcOO4GdDDE3p6uth7rfv9z0eFBj0og4UU9rlq9eRi9FMZntD AMRzf+seBSJBau41/Ia0YncoDt2l8jnXHESd2b/QSQHG3HAW0AYqh8YxelvC0jmhDlBJBb Kj+n8R64Ipyzkwezm6KF6XSENSyMl2o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646318894; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WEpl2zxA/wMor/6h90eumJW1A6bcL7xQObRg2Q3NI8M=; b=zIzUC9J6Ml+5oi7ZyRWUIim299SXM1UiaXy1x3xkDlN12YumAOmdk/F6Y9UimK1/2kRv/W b6XsxBF6HOuxHHCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0037E13AD9 for ; Thu, 3 Mar 2022 14:48:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YPWLOi3VIGL5AgAAMHmgww (envelope-from ) for ; Thu, 03 Mar 2022 14:48:13 +0000 From: Cyril Hrubis To: ltp@lists.linux.it Date: Thu, 3 Mar 2022 15:50:28 +0100 Message-Id: <20220303145032.21493-4-chrubis@suse.cz> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220303145032.21493-1-chrubis@suse.cz> References: <20220303145032.21493-1-chrubis@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH 3/7] mem/ksm06: Move test code from library to the test 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" There is no point in keeping the test code in the library since ksm06 is the only test that actually uses it. Signed-off-by: Cyril Hrubis Reviewed-by: Richard Palethorpe --- testcases/kernel/mem/ksm/ksm06.c | 82 +++++++++++++++++++++++++++++- testcases/kernel/mem/lib/mem.c | 85 -------------------------------- 2 files changed, 81 insertions(+), 86 deletions(-) diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c index 379236f1f..0f5e4b05d 100644 --- a/testcases/kernel/mem/ksm/ksm06.c +++ b/testcases/kernel/mem/ksm/ksm06.c @@ -48,7 +48,87 @@ static char *n_opt; static void test_ksm(void) { - test_ksm_merge_across_nodes(nr_pages); + char **memory; + int i, ret; + int num_nodes, *nodes; + unsigned long length; + unsigned long pagesize; + +#ifdef HAVE_NUMA_V2 + unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 }; +#endif + + ret = get_allowed_nodes_arr(NH_MEMS, &num_nodes, &nodes); + if (ret != 0) + tst_brk(TBROK|TERRNO, "get_allowed_nodes_arr"); + if (num_nodes < 2) { + tst_res(TINFO, "need NUMA system support"); + free(nodes); + return; + } + + pagesize = sysconf(_SC_PAGE_SIZE); + length = nr_pages * pagesize; + + memory = SAFE_MALLOC(num_nodes * sizeof(char *)); + for (i = 0; i < num_nodes; i++) { + memory[i] = SAFE_MMAP(NULL, length, PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); +#ifdef HAVE_DECL_MADV_MERGEABLE + if (madvise(memory[i], length, MADV_MERGEABLE) == -1) + tst_brk(TBROK|TERRNO, "madvise"); +#endif + +#ifdef HAVE_NUMA_V2 + clean_node(nmask); + set_node(nmask, nodes[i]); + /* + * Use mbind() to make sure each node contains + * length size memory. + */ + ret = mbind(memory[i], length, MPOL_BIND, nmask, MAXNODES, 0); + if (ret == -1) + tst_brk(TBROK|TERRNO, "mbind"); +#endif + + memset(memory[i], 10, length); + + if (mlock(memory[i], length)) + tst_res(TWARN | TERRNO, "mlock() failed"); + } + + SAFE_FILE_PRINTF(PATH_KSM "sleep_millisecs", "0"); + SAFE_FILE_PRINTF(PATH_KSM "pages_to_scan", "%ld", + nr_pages * num_nodes); + /* + * merge_across_nodes and max_page_sharing setting can be changed + * only when there are no ksm shared pages in system, so set run 2 + * to unmerge pages first, then to 1 after changing merge_across_nodes, + * to remerge according to the new setting. + */ + SAFE_FILE_PRINTF(PATH_KSM "run", "2"); + if (access(PATH_KSM "max_page_sharing", F_OK) == 0) + SAFE_FILE_PRINTF(PATH_KSM "max_page_sharing", + "%ld", nr_pages * num_nodes); + tst_res(TINFO, "Start to test KSM with merge_across_nodes=1"); + SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1"); + SAFE_FILE_PRINTF(PATH_KSM "run", "1"); + ksm_group_check(1, 1, nr_pages * num_nodes - 1, 0, 0, 0, + nr_pages * num_nodes); + + SAFE_FILE_PRINTF(PATH_KSM "run", "2"); + tst_res(TINFO, "Start to test KSM with merge_across_nodes=0"); + SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "0"); + SAFE_FILE_PRINTF(PATH_KSM "run", "1"); + ksm_group_check(1, num_nodes, nr_pages * num_nodes - num_nodes, + 0, 0, 0, nr_pages * num_nodes); + + SAFE_FILE_PRINTF(PATH_KSM "run", "2"); + + for (i = 0; i < num_nodes; i++) + SAFE_MUNMAP(memory[i], length); + + free(memory); } static void setup(void) diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index 102fc5665..090569ebb 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -519,91 +519,6 @@ void create_same_memory(int size, int num, int unit) WEXITSTATUS(status)); } -void test_ksm_merge_across_nodes(unsigned long nr_pages) -{ - char **memory; - int i, ret; - int num_nodes, *nodes; - unsigned long length; - unsigned long pagesize; - -#ifdef HAVE_NUMA_V2 - unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 }; -#endif - - ret = get_allowed_nodes_arr(NH_MEMS, &num_nodes, &nodes); - if (ret != 0) - tst_brk(TBROK|TERRNO, "get_allowed_nodes_arr"); - if (num_nodes < 2) { - tst_res(TINFO, "need NUMA system support"); - free(nodes); - return; - } - - pagesize = sysconf(_SC_PAGE_SIZE); - length = nr_pages * pagesize; - - memory = SAFE_MALLOC(num_nodes * sizeof(char *)); - for (i = 0; i < num_nodes; i++) { - memory[i] = SAFE_MMAP(NULL, length, PROT_READ|PROT_WRITE, - MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); -#ifdef HAVE_DECL_MADV_MERGEABLE - if (madvise(memory[i], length, MADV_MERGEABLE) == -1) - tst_brk(TBROK|TERRNO, "madvise"); -#endif - -#ifdef HAVE_NUMA_V2 - clean_node(nmask); - set_node(nmask, nodes[i]); - /* - * Use mbind() to make sure each node contains - * length size memory. - */ - ret = mbind(memory[i], length, MPOL_BIND, nmask, MAXNODES, 0); - if (ret == -1) - tst_brk(TBROK|TERRNO, "mbind"); -#endif - - memset(memory[i], 10, length); - - if (mlock(memory[i], length)) - tst_res(TWARN | TERRNO, "mlock() failed"); - } - - SAFE_FILE_PRINTF(PATH_KSM "sleep_millisecs", "0"); - SAFE_FILE_PRINTF(PATH_KSM "pages_to_scan", "%ld", - nr_pages * num_nodes); - /* - * merge_across_nodes and max_page_sharing setting can be changed - * only when there are no ksm shared pages in system, so set run 2 - * to unmerge pages first, then to 1 after changing merge_across_nodes, - * to remerge according to the new setting. - */ - SAFE_FILE_PRINTF(PATH_KSM "run", "2"); - if (access(PATH_KSM "max_page_sharing", F_OK) == 0) - SAFE_FILE_PRINTF(PATH_KSM "max_page_sharing", - "%ld", nr_pages * num_nodes); - tst_res(TINFO, "Start to test KSM with merge_across_nodes=1"); - SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1"); - SAFE_FILE_PRINTF(PATH_KSM "run", "1"); - ksm_group_check(1, 1, nr_pages * num_nodes - 1, 0, 0, 0, - nr_pages * num_nodes); - - SAFE_FILE_PRINTF(PATH_KSM "run", "2"); - tst_res(TINFO, "Start to test KSM with merge_across_nodes=0"); - SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "0"); - SAFE_FILE_PRINTF(PATH_KSM "run", "1"); - ksm_group_check(1, num_nodes, nr_pages * num_nodes - num_nodes, - 0, 0, 0, nr_pages * num_nodes); - - SAFE_FILE_PRINTF(PATH_KSM "run", "2"); - - for (i = 0; i < num_nodes; i++) - SAFE_MUNMAP(memory[i], length); - - free(memory); -} - /* THP */ /* cpuset/memcg */ From patchwork Thu Mar 3 14:50:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1600380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=mokQQZvX; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Wo9qITuy; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8Ylh00H7z9sG3 for ; Fri, 4 Mar 2022 01:49:03 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 9FC033CA350 for ; Thu, 3 Mar 2022 15:49:00 +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 RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 8EE7B3CA32E for ; Thu, 3 Mar 2022 15:48:15 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 39516600066 for ; Thu, 3 Mar 2022 15:48:15 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B014A210FA for ; Thu, 3 Mar 2022 14:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646318894; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vWi0AUGdEtvnPuasdO2mnyqmBObyJp9VQik3I1F5tKY=; b=mokQQZvXemQm/YEdMXmnZcPOPStrJOfWq6y3/Cxq9kgYbCgYP/ak08U4HivSUgbyVA+vK4 JqifdJc7Ql93vb+S88PlPrHLkUcmT5XdNYEE5acS9xR1P1bHeRJsuj5o3HHTwkHNBmyV3S kwC4DRMv7S0ZKcFCxooufWfqrmNY8js= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646318894; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vWi0AUGdEtvnPuasdO2mnyqmBObyJp9VQik3I1F5tKY=; b=Wo9qITuy6CZo5k57nf1ehApgnNlj+ucS4BSlWHrhRzoPyqpDk7bsRUuaIvJj2mRA8VHuvR tVpI8I0k+yB40qDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9A38913AD9 for ; Thu, 3 Mar 2022 14:48:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CtyLIy7VIGL+AgAAMHmgww (envelope-from ) for ; Thu, 03 Mar 2022 14:48:14 +0000 From: Cyril Hrubis To: ltp@lists.linux.it Date: Thu, 3 Mar 2022 15:50:29 +0100 Message-Id: <20220303145032.21493-5-chrubis@suse.cz> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220303145032.21493-1-chrubis@suse.cz> References: <20220303145032.21493-1-chrubis@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH 4/7] mem/ksm06: SPDX + docparse comment 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Cyril Hrubis Reviewed-by: Richard Palethorpe --- testcases/kernel/mem/ksm/ksm06.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c index 0f5e4b05d..61507b2aa 100644 --- a/testcases/kernel/mem/ksm/ksm06.c +++ b/testcases/kernel/mem/ksm/ksm06.c @@ -1,24 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2013-2017 Red Hat, Inc. + */ +/*\ + * [Description] * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * The case is designed to test sysfs boolean knob + * /sys/kernel/mm/ksm/merge_across_nodes. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - */ - -/* - * The case is designed to test new sysfs boolean knob - * /sys/kernel/mm/ksm/merge_across_nodes, which was introduced by - * commit 90bd6fd31c8097ee (ksm: allow trees per NUMA node). - * when merge_across_nodes is set to zero only pages from the same + * When merge_across_nodes is set to zero only pages from the same * node are merged, otherwise pages from all nodes can be merged * together. + * + * Introduced in commit: + * + * commit 90bd6fd31c8097ee4ddcb74b7e08363134863de5 + * Author: Petr Holasek + * Date: Fri Feb 22 16:35:00 2013 -0800 + * + * ksm: allow trees per NUMA node */ #include "config.h" From patchwork Thu Mar 3 14:50:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1600382 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=IcGSgZrC; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=7VAifuAi; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8Ylr72tXz9sG3 for ; Fri, 4 Mar 2022 01:49:12 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C49A93CA330 for ; Thu, 3 Mar 2022 15:49:10 +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 RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 23FEB3CA32A for ; Thu, 3 Mar 2022 15:48:16 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id A13D52001D9 for ; Thu, 3 Mar 2022 15:48:15 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3F44D218A9 for ; Thu, 3 Mar 2022 14:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646318895; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tn3X5M987hJm+Fe0DCF8nlHgc44ZcG7vvlLwnlJgjIM=; b=IcGSgZrCpFTIUUDVb8sbiJRVyw/QTxc7SLN73tvoBYislkwf2mZ2aaX2l36gkMii4bhZri 00tiiSOJ45PvQlZxzWbbVDDURZBeLVgmlKmgPSOWXnmAqACkePnHIuzFBMBw4XYfTjnSAX dUQyFXj2S4LOfPGiSmS01aPB5Nha85c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646318895; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tn3X5M987hJm+Fe0DCF8nlHgc44ZcG7vvlLwnlJgjIM=; b=7VAifuAi+6oGSMWpN91qTvRSyuiPRP9zkhso6XL/relhbvBh8Uar8XWLjo+SpOg6m0hXf2 A4wyBH/OlW4ZXVAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2D1BA13AD9 for ; Thu, 3 Mar 2022 14:48:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2ARcCS/VIGIAAwAAMHmgww (envelope-from ) for ; Thu, 03 Mar 2022 14:48:15 +0000 From: Cyril Hrubis To: ltp@lists.linux.it Date: Thu, 3 Mar 2022 15:50:30 +0100 Message-Id: <20220303145032.21493-6-chrubis@suse.cz> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220303145032.21493-1-chrubis@suse.cz> References: <20220303145032.21493-1-chrubis@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH 5/7] mem/ksm06: Move ksm restoration into the tst_test struct 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Cyril Hrubis --- testcases/kernel/mem/ksm/ksm06.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c index 61507b2aa..f5f7319d7 100644 --- a/testcases/kernel/mem/ksm/ksm06.c +++ b/testcases/kernel/mem/ksm/ksm06.c @@ -39,9 +39,6 @@ #ifdef HAVE_NUMA_V2 #include -static int run = -1; -static int sleep_millisecs = -1; -static int merge_across_nodes = -1; static unsigned long nr_pages = 100; static char *n_opt; @@ -141,27 +138,6 @@ static void setup(void) if (n_opt) nr_pages = SAFE_STRTOUL(n_opt, 0, ULONG_MAX); - - /* save the current value */ - SAFE_FILE_SCANF(PATH_KSM "run", "%d", &run); - SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes", - "%d", &merge_across_nodes); - SAFE_FILE_SCANF(PATH_KSM "sleep_millisecs", - "%d", &sleep_millisecs); -} - -static void cleanup(void) -{ - if (merge_across_nodes != -1) { - FILE_PRINTF(PATH_KSM "merge_across_nodes", - "%d", merge_across_nodes); - } - - if (sleep_millisecs != -1) - FILE_PRINTF(PATH_KSM "sleep_millisecs", "%d", sleep_millisecs); - - if (run != -1) - FILE_PRINTF(PATH_KSM "run", "%d", run); } static struct tst_test test = { @@ -171,9 +147,11 @@ static struct tst_test test = { {} }, .setup = setup, - .cleanup = cleanup, .save_restore = (const char * const[]) { "?/sys/kernel/mm/ksm/max_page_sharing", + "?/sys/kernel/mm/ksm/run", + "?/sys/kernel/mm/ksm/merge_across_nodes", + "?/sys/kernel/mm/ksm/sleep_millisecs", NULL, }, .test_all = test_ksm, From patchwork Thu Mar 3 14:50:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1600383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=qe1XNpCh; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TCc0Rz4W; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8Ym33sc2z9sG3 for ; Fri, 4 Mar 2022 01:49:23 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C1AD53C0739 for ; Thu, 3 Mar 2022 15:49:20 +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 [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 48DF33CA366 for ; Thu, 3 Mar 2022 15:48:16 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 3C3FB10005ED for ; Thu, 3 Mar 2022 15:48:16 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BE3C4210FA for ; Thu, 3 Mar 2022 14:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646318895; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DNn6CcIjeWnX7BNwqT8E77YG8VnzqpEfPDqkvgq47l0=; b=qe1XNpChe9ucLwmBFacJLpzRpanMoO95MtqML0zWTBtFsDyLOyxNY4HIUIEY6aVTG/ZEfp xOhTr4Y0e/gRSNbTKvHQXa2mBAWWGvX1ruK+3bSsf22ngK/jEa95ckUD+7xljRY8XEtpgm 6tnHb8ku2BTyKIifA/7emUKDOmIFu2M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646318895; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DNn6CcIjeWnX7BNwqT8E77YG8VnzqpEfPDqkvgq47l0=; b=TCc0Rz4W84zmD6yvmksDCrjjNa9VMLGzZJmQ/4siEEBJsa4aZNQi1gHMKorVFKFATw9vQB QArbVxwj4IxIrPAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A9FD013AD9 for ; Thu, 3 Mar 2022 14:48:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id dE53KC/VIGICAwAAMHmgww (envelope-from ) for ; Thu, 03 Mar 2022 14:48:15 +0000 From: Cyril Hrubis To: ltp@lists.linux.it Date: Thu, 3 Mar 2022 15:50:31 +0100 Message-Id: <20220303145032.21493-7-chrubis@suse.cz> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220303145032.21493-1-chrubis@suse.cz> References: <20220303145032.21493-1-chrubis@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 6/7] libs: libltpnuma: Fix free memory estimate 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" On long running systems most of the memory would be consumed by a file page cache which is reclaimable. Because of that the numa test will be skipped even if the system has plenty of memory. To fix this this patch adds 90% of the memory used by the page cache to the free memory estimate. Signed-off-by: Cyril Hrubis Reviewed-by: Li Wang --- libs/libltpnuma/tst_numa.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/libltpnuma/tst_numa.c b/libs/libltpnuma/tst_numa.c index 417d98ced..7b8c4bc79 100644 --- a/libs/libltpnuma/tst_numa.c +++ b/libs/libltpnuma/tst_numa.c @@ -129,6 +129,7 @@ static int node_has_enough_memory(int node, size_t min_kb) char buf[1024]; long mem_total = 0; long mem_used = 0; + long file_pages = 0; /* Make sure there is some space for kernel upkeeping as well */ min_kb += 4096; @@ -152,6 +153,9 @@ static int node_has_enough_memory(int node, size_t min_kb) if (sscanf(buf, "%*s %*i MemUsed: %li", &val) == 1) mem_used = val; + + if (sscanf(buf, "%*s %*i FilePages: %li", &val) == 1) + file_pages = val; } fclose(fp); @@ -161,7 +165,7 @@ static int node_has_enough_memory(int node, size_t min_kb) return 0; } - if (mem_total - mem_used < (long)min_kb) { + if (mem_total - mem_used + (9 * file_pages)/10 < (long)min_kb) { tst_res(TINFO, "Not enough free RAM on node %i, have %likB needs %zukB", node, mem_total - mem_used, min_kb); From patchwork Thu Mar 3 14:50:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1600384 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=fq3x6GAz; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=dGYDsDpK; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8YmG5Qbyz9sG3 for ; Fri, 4 Mar 2022 01:49:34 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E3FFE3CA327 for ; Thu, 3 Mar 2022 15:49:31 +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 [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 52BC83CA367 for ; Thu, 3 Mar 2022 15:48:17 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id B0D2F100093A for ; Thu, 3 Mar 2022 15:48:16 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 53E2E218A9 for ; Thu, 3 Mar 2022 14:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646318896; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kwp+ljcUno/J/iTa0fw0s4BsQPCM6GZMpJi8wNH5TrM=; b=fq3x6GAz3s24VfkHdqgUBxf79dHUtp9Hn/KdyUsTvaI5c/s/5PzG8uKwq3lat67NJBBSyH 2GgySxMe/vqnRZXQK5LaEwqx9Rfs5Dy6SqPW28hHV6R1r1KHXDItjVa379jZRamPQiwGXn gnclqFeb/rbrK/XKw+OEvWe6IWf85rw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646318896; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kwp+ljcUno/J/iTa0fw0s4BsQPCM6GZMpJi8wNH5TrM=; b=dGYDsDpKhM+Ck+HOd4MWB9OJb635H5PFBhAXnhvdNoQixsaGFb96cDULcpRhPUl/P63awv oHivwALtwmTxErCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3B2C013AD9 for ; Thu, 3 Mar 2022 14:48:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id m+iwCzDVIGIEAwAAMHmgww (envelope-from ) for ; Thu, 03 Mar 2022 14:48:16 +0000 From: Cyril Hrubis To: ltp@lists.linux.it Date: Thu, 3 Mar 2022 15:50:32 +0100 Message-Id: <20220303145032.21493-8-chrubis@suse.cz> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220303145032.21493-1-chrubis@suse.cz> References: <20220303145032.21493-1-chrubis@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 7/7] mem/ksm06: Make use of the new libltpnuma 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" THe main benefit is that the new library also makes sure that memory nodes have enough memory for the test. Signed-off-by: Cyril Hrubis Reviewed-by: Li Wang --- testcases/kernel/mem/ksm/Makefile | 3 ++ testcases/kernel/mem/ksm/ksm06.c | 72 ++++++++++++++----------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/testcases/kernel/mem/ksm/Makefile b/testcases/kernel/mem/ksm/Makefile index e8ea801bc..236625690 100644 --- a/testcases/kernel/mem/ksm/Makefile +++ b/testcases/kernel/mem/ksm/Makefile @@ -3,6 +3,9 @@ top_srcdir ?= ../../../.. +LTPLIBS = ltpnuma +ksm06: LTPLDLIBS = -lltpnuma + include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c index f5f7319d7..80426bbb0 100644 --- a/testcases/kernel/mem/ksm/ksm06.c +++ b/testcases/kernel/mem/ksm/ksm06.c @@ -34,41 +34,30 @@ #include #include "mem.h" -#include "numa_helper.h" +#include "tst_numa.h" #ifdef HAVE_NUMA_V2 -#include +# include +# include static unsigned long nr_pages = 100; - static char *n_opt; +static size_t page_size; +static struct tst_nodemap *nodes; + static void test_ksm(void) { char **memory; - int i, ret; - int num_nodes, *nodes; + unsigned int i; + int ret; unsigned long length; - unsigned long pagesize; - -#ifdef HAVE_NUMA_V2 - unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 }; -#endif - - ret = get_allowed_nodes_arr(NH_MEMS, &num_nodes, &nodes); - if (ret != 0) - tst_brk(TBROK|TERRNO, "get_allowed_nodes_arr"); - if (num_nodes < 2) { - tst_res(TINFO, "need NUMA system support"); - free(nodes); - return; - } + struct bitmask *bm = numa_allocate_nodemask(); - pagesize = sysconf(_SC_PAGE_SIZE); - length = nr_pages * pagesize; + length = nr_pages * page_size; - memory = SAFE_MALLOC(num_nodes * sizeof(char *)); - for (i = 0; i < num_nodes; i++) { + memory = SAFE_MALLOC(nodes->cnt * sizeof(char *)); + for (i = 0; i < nodes->cnt; i++) { memory[i] = SAFE_MMAP(NULL, length, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); #ifdef HAVE_DECL_MADV_MERGEABLE @@ -77,15 +66,13 @@ static void test_ksm(void) #endif #ifdef HAVE_NUMA_V2 - clean_node(nmask); - set_node(nmask, nodes[i]); - /* - * Use mbind() to make sure each node contains - * length size memory. - */ - ret = mbind(memory[i], length, MPOL_BIND, nmask, MAXNODES, 0); + numa_bitmask_setbit(bm, nodes->map[i]); + + ret = mbind(memory[i], length, MPOL_BIND, bm->maskp, bm->size+1, 0); if (ret == -1) tst_brk(TBROK|TERRNO, "mbind"); + + numa_bitmask_clearbit(bm, nodes->map[i]); #endif memset(memory[i], 10, length); @@ -94,9 +81,11 @@ static void test_ksm(void) tst_res(TWARN | TERRNO, "mlock() failed"); } + numa_free_nodemask(bm); + SAFE_FILE_PRINTF(PATH_KSM "sleep_millisecs", "0"); SAFE_FILE_PRINTF(PATH_KSM "pages_to_scan", "%ld", - nr_pages * num_nodes); + nr_pages * nodes->cnt); /* * merge_across_nodes and max_page_sharing setting can be changed * only when there are no ksm shared pages in system, so set run 2 @@ -106,23 +95,23 @@ static void test_ksm(void) SAFE_FILE_PRINTF(PATH_KSM "run", "2"); if (access(PATH_KSM "max_page_sharing", F_OK) == 0) SAFE_FILE_PRINTF(PATH_KSM "max_page_sharing", - "%ld", nr_pages * num_nodes); + "%ld", nr_pages * nodes->cnt); tst_res(TINFO, "Start to test KSM with merge_across_nodes=1"); SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1"); SAFE_FILE_PRINTF(PATH_KSM "run", "1"); - ksm_group_check(1, 1, nr_pages * num_nodes - 1, 0, 0, 0, - nr_pages * num_nodes); + ksm_group_check(1, 1, nr_pages * nodes->cnt - 1, 0, 0, 0, + nr_pages * nodes->cnt); SAFE_FILE_PRINTF(PATH_KSM "run", "2"); tst_res(TINFO, "Start to test KSM with merge_across_nodes=0"); SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "0"); SAFE_FILE_PRINTF(PATH_KSM "run", "1"); - ksm_group_check(1, num_nodes, nr_pages * num_nodes - num_nodes, - 0, 0, 0, nr_pages * num_nodes); + ksm_group_check(1, nodes->cnt, nr_pages * nodes->cnt - nodes->cnt, + 0, 0, 0, nr_pages * nodes->cnt); SAFE_FILE_PRINTF(PATH_KSM "run", "2"); - for (i = 0; i < num_nodes; i++) + for (i = 0; i < nodes->cnt; i++) SAFE_MUNMAP(memory[i], length); free(memory); @@ -133,11 +122,14 @@ static void setup(void) if (access(PATH_KSM "merge_across_nodes", F_OK) == -1) tst_brk(TCONF, "no merge_across_nodes sysfs knob"); - if (!is_numa(NULL, NH_MEMS, 2)) - tst_brk(TCONF, "The case needs a NUMA system."); - if (n_opt) nr_pages = SAFE_STRTOUL(n_opt, 0, ULONG_MAX); + + page_size = getpagesize(); + + nodes = tst_get_nodemap(TST_NUMA_MEM, nr_pages * page_size / 1024); + if (nodes->cnt <= 1) + tst_brk(TCONF, "Test requires at least two NUMA memory nodes"); } static struct tst_test test = {