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 CC178C433F5 for ; Mon, 16 May 2022 23:28:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C2EE6B0072; Mon, 16 May 2022 19:28:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 270B96B0073; Mon, 16 May 2022 19:28:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 112136B0074; Mon, 16 May 2022 19:28:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 02B706B0072 for ; Mon, 16 May 2022 19:28:04 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C56DE60881 for ; Mon, 16 May 2022 23:28:04 +0000 (UTC) X-FDA: 79473196488.23.F47091A Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) by imf01.hostedemail.com (Postfix) with ESMTP id A62B140029 for ; Mon, 16 May 2022 23:27:49 +0000 (UTC) Received: by mail-il1-f172.google.com with SMTP id f9so1858958ils.7 for ; Mon, 16 May 2022 16:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=aB42P+32Sum2YGY8sIwFisRp1PF9vp9paSBH6A92ZaE=; b=Zv6HbJakhqS+8wMgeAmCsL+LluuM1WF/O/iD6PBZbTfwaeoxl+nGIXjE0bxK3qLegV rZW7Cm8pz7iuOCC10rLuWZIo+EWIs3JKeOwt3XQu3Vv5z7pwl+sjDUwqFeUCC/RluqIs EIx+Op8FRpoPxCIwiSmmxs5FlU8Ez8p/fHPf0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aB42P+32Sum2YGY8sIwFisRp1PF9vp9paSBH6A92ZaE=; b=JmGPzwhxTCX/e4cV7DAXWCWjhmXlAKZmRLU1DXqO0uXom5DSfUcv+hgikOL910Yjog XP2G4i4lueNJp/XQgbQHwBj06fRiz22OVw4j+QSMHQDgZrE3zXOihosyaJT81WH69KDw VUi/B8FMiEVAEiSAUOpryby8517ZssGKS50LpZtOqTfwzCNC7Y9t76XuB8+f8gyMhIGs KRjuNCPQ/dNTc8m4Pid5CTb7piBPBd7VS6hhbLJ60uIy9cigqdK5bG03lOEzAydMGxPA VnZbXADMRfQ+KUVpFI5Qnpes1ZSR1CmhgXzZeoIxWJ/vI7NN3hOUuLJ7k7fRC10MY4pG enMw== X-Gm-Message-State: AOAM533qNqXp4I5oeZEvWjNLDpZijd8McvuS/7ZWHEusf/kwxAFBKa5Q orVpKBBuHmReTVXBlMj3uMfUxw== X-Google-Smtp-Source: ABdhPJzjAxpWuSAl3NSm2jw1j14nzqb8OMF43VWfK8MkCFKfzvQ5EPRFC8NsalLmZGBu91pdgn8guQ== X-Received: by 2002:a05:6e02:1905:b0:2cf:1afa:7523 with SMTP id w5-20020a056e02190500b002cf1afa7523mr10791194ilu.234.1652743683444; Mon, 16 May 2022 16:28:03 -0700 (PDT) Received: from [192.168.1.128] ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id d76-20020a6bcd4f000000b0065a9e81df9dsm202417iog.4.2022.05.16.16.28.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 May 2022 16:28:02 -0700 (PDT) Subject: Re: [PATCH v2 1/1] selftests: vm: add process_mrelease tests To: Suren Baghdasaryan Cc: Andrew Morton , Michal Hocko , David Rientjes , Matthew Wilcox , Johannes Weiner , Roman Gushchin , Minchan Kim , "Kirill A. Shutemov" , Andrea Arcangeli , Christian Brauner , Christoph Hellwig , Oleg Nesterov , David Hildenbrand , Jann Horn , Shakeel Butt , Peter Xu , John Hubbard , shuah@kernel.org, LKML , linux-mm , linux-kselftest@vger.kernel.org, kernel-team , Shuah Khan References: <20220516075538.1276644-1-surenb@google.com> <78c3a163-551b-ef53-4018-7b6ba0640757@linuxfoundation.org> From: Shuah Khan Message-ID: <7f0fd407-18f5-2718-40b5-b16804163197@linuxfoundation.org> Date: Mon, 16 May 2022 17:28:01 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=Zv6HbJak; spf=pass (imf01.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.166.172 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A62B140029 X-Stat-Signature: qpzknmjes3gofdip3t98ekb1gn1pguyu X-HE-Tag: 1652743669-459265 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 5/16/22 2:47 PM, Suren Baghdasaryan wrote: > On Mon, May 16, 2022 at 1:29 PM Shuah Khan wrote: >> >> On 5/16/22 1:55 AM, Suren Baghdasaryan wrote: >>> Introduce process_mrelease syscall sanity tests which include tests >>> which expect to fail: >>> - process_mrelease with invalid pidfd and flags inputs >>> - process_mrelease on a live process with no pending signals >>> and valid process_mrelease usage which is expected to succeed. >>> Because process_mrelease has to be used against a process with a pending >>> SIGKILL, it's possible that the process exits before process_mrelease >>> gets called. In such cases we retry the test with a victim that allocates >>> twice more memory up to 1GB. This would require the victim process to >>> spend more time during exit and process_mrelease has a better chance of >>> catching the process before it exits and succeeding. >>> >>> On success the test reports the amount of memory the child had to >>> allocate for reaping to succeed. Sample output: >>> Success reaping a child with 1MB of memory allocations >>> >>> On failure the test reports the failure. Sample outputs: >>> All process_mrelease attempts failed! >>> process_mrelease: Invalid argument >>> >> >> Nit: Please format this better - include actual example output from the >> command and how to run the test examples. > > Hmm... Those are the actual outputs from the command and it does not > take any input arguments. Do you mean smth like this: > > $ mrelease_test > Success reaping a child with 1MB of memory allocations > > $ mrelease_test > All process_mrelease attempts failed! > > $ mrelease_test > process_mrelease: Invalid argument > > ? This looks good. > >> >>> Signed-off-by: Suren Baghdasaryan >>> --- >>> tools/testing/selftests/vm/.gitignore | 1 + >>> tools/testing/selftests/vm/Makefile | 1 + >>> tools/testing/selftests/vm/mrelease_test.c | 214 +++++++++++++++++++++ >>> tools/testing/selftests/vm/run_vmtests.sh | 16 ++ >>> 4 files changed, 232 insertions(+) >>> create mode 100644 tools/testing/selftests/vm/mrelease_test.c >>> [snip] >> >> Okay these above 3 routines are called once. I am not seeing any point >> in making these separate routines. I made the same comment on v1. > > I must have misunderstood your previous comment. Will change. > Thank you. >> >> >> Now the above code can be a separate function which will make it readable. > > Ack. > >> >>> + >> >> Why do you need these ifdefs - syscall will return ENOSYS and you can >> key off that. Please take a look at other usages of syscall in the >> repo. > > The issue is that I need to provide the syscall number when calling > syscall() (in my case __NR_pidfd_open and __NR_process_mrelease) and > if that number is not defined in the userspace headers on a given > system then what should I pass instead? > When implementing this I followed the examples of > https://elixir.bootlin.com/linux/latest/source/tools/testing/selftests/vm/memfd_secret.c#L30 > and https://elixir.bootlin.com/linux/latest/source/tools/testing/selftests/vm/userfaultfd.c#L65. > My original implementation was modeled after this approach: > https://elixir.bootlin.com/linux/latest/source/tools/testing/selftests/vm/mlock2.h#L15. > If none of these are correct, could you please point me to the example > you want me to follow? > kselftests include kernel headers. As long as these syscalls are defined in the kernel headers, the test will build. Looks it is defined in include/uapi/asm-generic/unistd.h You can assume it is defined and then if we find architectures that don't, you can follow what tools/testing/selftests/pidfd/pidfd.h does. This way the test can simply call syscall and handle ENOSYS. thanks, -- Shuah