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 74100C433F5 for ; Mon, 16 May 2022 23:51:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA8F66B0072; Mon, 16 May 2022 19:51:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B58046B0073; Mon, 16 May 2022 19:51:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F7ED6B0074; Mon, 16 May 2022 19:51:55 -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 919CE6B0072 for ; Mon, 16 May 2022 19:51:55 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 69FD361524 for ; Mon, 16 May 2022 23:51:55 +0000 (UTC) X-FDA: 79473256590.14.59761C0 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf16.hostedemail.com (Postfix) with ESMTP id 14E3E180014 for ; Mon, 16 May 2022 23:51:43 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id j84so18897297ybc.3 for ; Mon, 16 May 2022 16:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=i606HfEWVO/qnL8GVN8QjqxjzHn2kHFuQ0+GTOY9ccY=; b=n+DIO+7/hs5dubTKEpbxjG3NWXawGNH+U5W3/PTMqu1oU0UFB9TtNUYil1wX+uO6yH naYC4DdWVKhp384hBvQJSkpBNrFmunkQbfljVYDe7NdgbOZXE6OdvV/9UV5HaVzr4U/G Ozw1o91PaZqKW+xWqVTDMRKC402IK5R8WjYODJ7cAJa65THZWGX8kut+xKsfzhfB37Et 7PvY2KVP3rbyrRpbJEv6snQanikc9Bm68A2JmNYS5qml1jJcp+wyNolOD5mxUs087RFM w5OYrjpQs1PN36UXYIwvth6TRpSpIiHayEsbY2xabi0fhhvPRZoHX85Vb0McblFrLATl KMNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=i606HfEWVO/qnL8GVN8QjqxjzHn2kHFuQ0+GTOY9ccY=; b=3V++0X5rI+IIssgplPInYkegmg6qV3kzvJHDrb/DWnIKKK/x0X3pFh+oNEcviub9y4 xpjn9jEeXSQ8ZtgI/fgEgp6U3HJ4sRJ59+X4/RbWx6Bgu837XuRYvItqiRwo1J3Durlu I8lldfet+2SnoLQ8zmJMfO3Ed/HYquKrAjPN3Zguve/KySxOgF/YOUPXK3Q69Fft2kE7 rjPdqtm5REetFoWsELNgNIYYlU6+drKqUK18xLzpJ0bckTKhZLSESc8ZF33Z9zPDAtE8 uZXSBDeusTWDPZ2p3ptxI0Lm8c41FlzHYujcXo3nRIiIpt9eLwIxYkM61azM7JCYqh9R 6LBQ== X-Gm-Message-State: AOAM530X6lGjTVMC9sTMAI0l10GUmzPHeJADCX6KSM8/Wfl1aeYaDCRt V46nwvVZsdDjxSqGsZtmyjxeYWbJ92FpRa9gatsHdA== X-Google-Smtp-Source: ABdhPJyTW5XuzXVi3sj4DqnD1ld6DZCkzmQw1+kKkUEO2Q4whnBJnGiGh0ctOzXzfOqXqHcJeD9HZd0WZDI5Y5IaHSQ= X-Received: by 2002:a05:6902:389:b0:633:31c1:d0f7 with SMTP id f9-20020a056902038900b0063331c1d0f7mr19940675ybs.543.1652745114021; Mon, 16 May 2022 16:51:54 -0700 (PDT) MIME-Version: 1.0 References: <20220516075538.1276644-1-surenb@google.com> <78c3a163-551b-ef53-4018-7b6ba0640757@linuxfoundation.org> <7f0fd407-18f5-2718-40b5-b16804163197@linuxfoundation.org> In-Reply-To: <7f0fd407-18f5-2718-40b5-b16804163197@linuxfoundation.org> From: Suren Baghdasaryan Date: Mon, 16 May 2022 16:51:43 -0700 Message-ID: Subject: Re: [PATCH v2 1/1] selftests: vm: add process_mrelease tests To: Shuah Khan 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 Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="n+DIO+7/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of surenb@google.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=surenb@google.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 14E3E180014 X-Rspam-User: X-Stat-Signature: wc63xfgrcdt6kradmf95j1rhymhp5h51 X-HE-Tag: 1652745103-95473 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 Mon, May 16, 2022 at 4:28 PM Shuah Khan wrote: > > 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 for the guidance! I'll try that approach. Suren. > > thanks, > -- Shuah > > > > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. >