From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DF15C77B61 for ; Thu, 13 Apr 2023 13:07:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81621900004; Thu, 13 Apr 2023 09:07:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C669900002; Thu, 13 Apr 2023 09:07:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68E3C900004; Thu, 13 Apr 2023 09:07:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 59F65900002 for ; Thu, 13 Apr 2023 09:07:42 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EF3E21A021E for ; Thu, 13 Apr 2023 13:07:41 +0000 (UTC) X-FDA: 80676394722.05.25B21B2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 57AD3C0012 for ; Thu, 13 Apr 2023 13:07:39 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VUfjnHpP; spf=pass (imf10.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681391259; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Xu3cDrGly0wJnGXrRec8HvQ04SIjk5VxPaKdFOL3odc=; b=7FM8b4/uJGGH7mWyOlNiLBOHVu8Z8UR0taHJ1qQiM5Pofn4nCbvQx+nsN9vDqIpZVnHV5W AhANNDvdfO3/6CpzEAOfkvgnFcPTeKwh3RR9dXoI56DvmZCpP/zDLmhhfdV6eT9tlpG2Dh YDEiSDiPW/teoN3+kUIQI/op1l2Hqag= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VUfjnHpP; spf=pass (imf10.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681391259; a=rsa-sha256; cv=none; b=6oYUsh2otBE9IwsFgmBFYeYb5sGnFkHXxbZg20AHyHKbWKCMRc3gpU4gXVbVhERAQfZdXn hwqXy5a6BZlDIEGf9WZ1O9wCHpjF4Qo1H7VPYsr+YdtfQlQEn4AgrDpxYceTOteXr1j1GO BuozGWqR7LMaMI3zbEDwLkRs0Y03ym4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681391258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xu3cDrGly0wJnGXrRec8HvQ04SIjk5VxPaKdFOL3odc=; b=VUfjnHpPFUyT8EVl+eiYEJZE6IrMjH/+eBDh9YmhanxeMugAeOFP7xZ0PNDxFu+BZLpovU 3WLHAfIsg3H03teVIOmeNKKvD91Ze4XiqMTF6dy98iaQ4mCzqwLKeMyyNPeNlbahfqX4WR C61au3o+25km0TjtC3F4XadzvTvmz0Y= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-IxYA8002Pk-MEl6JHexNmw-1; Thu, 13 Apr 2023 09:07:37 -0400 X-MC-Unique: IxYA8002Pk-MEl6JHexNmw-1 Received: by mail-wm1-f70.google.com with SMTP id z20-20020a05600c0a1400b003edcff41678so2049957wmp.0 for ; Thu, 13 Apr 2023 06:07:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681391256; x=1683983256; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Xu3cDrGly0wJnGXrRec8HvQ04SIjk5VxPaKdFOL3odc=; b=U9LKVgVKoUJiH3/V6RTdy/X3s1g/29y8DUTp5QkwVEsFzvYNlG4ow1t6I/k5qyFQIS 17yhMa8g6uzUyQdMfSB19MV/2n/3xyKhVwd8uvPZSYywX0Lo+fl6x2UhXi2up7BV7EPG LsZOOs939XwgBmR8AMifyZP29JbHrOD7i6DJt+ZfWQt1+IJY1ZJWcspQYWM87APtrs4v urnrHFLCsxRohpqcM1D9C0dJf5VU5ip11umm1STbABEQO+oXy0mpAXeB9+Lp+w1AtcSl rExYC3ZQ+pjczI0Blg0Vm6fxQ0GGQj+Y1wtuNnH4xJwNkj6+z00phoTR1zmGJr7rNLpw fEBg== X-Gm-Message-State: AAQBX9cBpMonyPy3cffvUwFlBVpdTgChviFCuPOCJxLfCJ5CjHdWzsld V+mMsjxwWm5wuxrVePqC3BzukkkEqVWzI1q5l+bKu+MCqc/9FeW/TJrwsB47IjjHSkZ+gv5QeXj og/N/eXGCeb4= X-Received: by 2002:adf:d0cc:0:b0:2cf:ec75:8090 with SMTP id z12-20020adfd0cc000000b002cfec758090mr1405071wrh.14.1681391256423; Thu, 13 Apr 2023 06:07:36 -0700 (PDT) X-Google-Smtp-Source: AKy350ZAf2dTIXalDT1vqm+8Q7R/XyJbZOQfYNc5Rhgq/eKzSYm1AAjZ4JIiIbog4wnJj4wKIcBFQA== X-Received: by 2002:adf:d0cc:0:b0:2cf:ec75:8090 with SMTP id z12-20020adfd0cc000000b002cfec758090mr1405053wrh.14.1681391256006; Thu, 13 Apr 2023 06:07:36 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id v11-20020a5d43cb000000b002f490a0cd1asm1246303wrr.92.2023.04.13.06.07.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Apr 2023 06:07:35 -0700 (PDT) Message-ID: <7c5606cc-ca58-c505-b0d3-2eec29fe606a@redhat.com> Date: Thu, 13 Apr 2023 15:07:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 To: Stefan Roesch , kernel-team@fb.com Cc: linux-mm@kvack.org, riel@surriel.com, mhocko@suse.com, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, akpm@linux-foundation.org, hannes@cmpxchg.org, willy@infradead.org, Bagas Sanjaya References: <20230412031648.2206875-1-shr@devkernel.io> <20230412031648.2206875-4-shr@devkernel.io> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v6 3/3] selftests/mm: add new selftests for KSM In-Reply-To: <20230412031648.2206875-4-shr@devkernel.io> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 57AD3C0012 X-Rspam-User: X-Stat-Signature: 89i486zgjhqdwpgf317biz36rrfou88r X-HE-Tag: 1681391259-546057 X-HE-Meta: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NjtET3ftY9IFoYGPlJ+PXdL3odTgj0L3lQxHnSr2YGK4ORN6Lik+Boaxqe6EeLxLs6kosAbaZksCRpJvmI+bMKj8vTOiapYmko8pXLGRUmo0365rSwFItL66q1kNLbOmTgExVgRnXmqW+deZFTdJIDv+kaWJ8k3JB84N4AhSJwsIhQH+XsgQqvxTD0118Q6gZQHK0+7Ir0m34RvXfBbuL5n47ZuNW8bA3I1uOY+snTVs0hKFC7x1GoW2iKxqHAN3Froi8i2iaxv3D812cdGn7tZGQ1y32FmAblcNgCH+cseo5kE2gRgFQMC8A/XYMExxRD6pMR9n6rF+xVwAEHC77U0fn8U= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 12.04.23 05:16, Stefan Roesch wrote: > This adds three new tests to the selftests for KSM. These tests use the > new prctl API's to enable and disable KSM. > > 1) add new prctl flags to prctl header file in tools dir > > This adds the new prctl flags to the include file prct.h in the > tools directory. This makes sure they are available for testing. > > 2) add KSM prctl merge test > > This adds the -t option to the ksm_tests program. The -t flag > allows to specify if it should use madvise or prctl ksm merging. > > 3) add KSM get merge type test > > This adds the -G flag to the ksm_tests program to query the KSM > status with prctl after KSM has been enabled with prctl. > > 4) add KSM fork test > > Add fork test to verify that the MMF_VM_MERGE_ANY flag is inherited > by the child process. > > 5) add two functions for debugging merge outcome > > This adds two functions to report the metrics in /proc/self/ksm_stat > and /sys/kernel/debug/mm/ksm. > > The debugging can be enabled with the following command line: > make -C tools/testing/selftests TARGETS="mm" --keep-going \ > EXTRA_CFLAGS=-DDEBUG=1 Would it make sense to instead have a "-D" (if still unused) runtime options to print this data? Dead code that's not compiled is a bit unfortunate as it can easily bit-rot. This patch essentially does two things 1) Add the option to run all tests/benchmarks with the PRCTL instead of MADVISE 2) Add some functional KSM tests for the new PRCTL (fork, enabling works, disabling works). The latter should rather go into ksm_functional_tests(). [...] > > -static int check_ksm_unmerge(int mapping, int prot, int timeout, size_t page_size) > +/* Verify that prctl ksm flag is inherited. */ > +static int check_ksm_fork(void) > +{ > + int rc = KSFT_FAIL; > + pid_t child_pid; > + > + if (prctl(PR_SET_MEMORY_MERGE, 1)) { > + perror("prctl"); > + return KSFT_FAIL; > + } > + > + child_pid = fork(); > + if (child_pid == 0) { > + int is_on = prctl(PR_GET_MEMORY_MERGE, 0); > + > + if (!is_on) > + exit(KSFT_FAIL); > + > + exit(KSFT_PASS); > + } > + > + if (child_pid < 0) > + goto out; > + > + if (waitpid(child_pid, &rc, 0) < 0) > + rc = KSFT_FAIL; > + > + if (prctl(PR_SET_MEMORY_MERGE, 0)) { > + perror("prctl"); > + rc = KSFT_FAIL; > + } > + > +out: > + if (rc == KSFT_PASS) > + printf("OK\n"); > + else > + printf("Not OK\n"); > + > + return rc; > +} > + > +static int check_ksm_get_merge_type(void) > +{ > + if (prctl(PR_SET_MEMORY_MERGE, 1)) { > + perror("prctl set"); > + return 1; > + } > + > + int is_on = prctl(PR_GET_MEMORY_MERGE, 0); > + > + if (prctl(PR_SET_MEMORY_MERGE, 0)) { > + perror("prctl set"); > + return 1; > + } > + > + int is_off = prctl(PR_GET_MEMORY_MERGE, 0); > + > + if (is_on && is_off) { > + printf("OK\n"); > + return KSFT_PASS; > + } > + > + printf("Not OK\n"); > + return KSFT_FAIL; > +} Yes, these two are better located in ksm_functional_tests() to just run them both automatically when the test is executed. -- Thanks, David / dhildenb