Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6289312iob; Tue, 10 May 2022 15:01:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiuMqfNCEK4ObE5h4FIwL6MMA7RxY7SWwoQMoxKLcKEJtx1htWtGJSqIzqdYs8OzZUeKf0 X-Received: by 2002:a17:90a:5886:b0:1dc:6b58:91e with SMTP id j6-20020a17090a588600b001dc6b58091emr1948975pji.176.1652220110580; Tue, 10 May 2022 15:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652220110; cv=none; d=google.com; s=arc-20160816; b=n0VS14hRjNQc5+FWx0Jh/eleWVBbEwKZ8Ee+fMEacFFce17AMXSGD5SxKRtcGaBsXx Mr2m4/X+jBUkLAVoxPA70H4qZn5s3LtFF1IfAsKT5YM+B1LzSg7QFxsWkRzVX1dj2crH eGJFfZbiZkabnnerbd8u3dUiFrNB28ZNjN6BmYguH77VTeJ3MBlY6WIkK2FcnkZDz62S eLo6TYGM2E25t+byHtCcWq8t0hX7Wh2Mc5I+kTmPol/AShZKn0Q9vMd6+3tTM0BsDZwV JVlpwYILJI4CtRhpCTv5IeQIs5xeBf6qWclL2fYHgLImS6N6Ztuso3vS6gGmMj0o5A0Z 2ArQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=HlN/qXnWAzpT0XOb6xZ1b8xPCTnujWMOoy9VjZoHjw8=; b=bNjFa8r4vOuavPno3Oft4J5ggmClcqweanuFjV8RVKaCYqEys7rFBi6Ywe+1dNNhtG Xknzc+9ciGq4ha3GZDTQ0oSHAnrqFW8kLAN1OYJdbchjIN17gIXeaRxeRLtD2UuzE5xj 8uLN6PuyItkZl+377VSJp+Hz9eS6JTG7KNI8fNx/SM4SPIJjUeLRm0TrBCqVJ+xlSlud L/C6NbFFQTehkO5AZlp/XNioutU03J4Yuh1mMzcXXV34mEAJJh01NbThFIni1InMwBz2 tLZ4adU8ec/HVLKgfgoL3Shyldt4MmZhAh7pO/QLNwfT+a5cWIxirWjHZorRqd/0pduW a8BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=igSVZrIt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a170903228f00b001582d18c33bsi526740plh.5.2022.05.10.15.01.36; Tue, 10 May 2022 15:01:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=igSVZrIt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347506AbiEJQkJ (ORCPT + 99 others); Tue, 10 May 2022 12:40:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347496AbiEJQkA (ORCPT ); Tue, 10 May 2022 12:40:00 -0400 Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 225DA2CDE1 for ; Tue, 10 May 2022 09:36:02 -0700 (PDT) Received: by mail-oo1-xc31.google.com with SMTP id y27-20020a4a9c1b000000b0032129651bb0so3314509ooj.2 for ; Tue, 10 May 2022 09:36:02 -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=HlN/qXnWAzpT0XOb6xZ1b8xPCTnujWMOoy9VjZoHjw8=; b=igSVZrItvpaAIWfSwmdQ+2sJD5RE7Dj0f2Xqwhu0KGvpZgTPz1h/UfTdbU8RtORw6X OYsdZqH3N9kneUqpwnqTaDbIhe7+rZisIsfWt7hGBpMiKYnC0DEUlODrpvlLeoM7Ke/3 gSJshV5rl+gTE4W/dIwTahy54Rq6ev+lZH2i0= 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=HlN/qXnWAzpT0XOb6xZ1b8xPCTnujWMOoy9VjZoHjw8=; b=0UKwfEIwtZn05JUs7Q25LiM8U4cowbVKiuCR4fYCuB6lEj6+s7vvz2yEy9zjlLkFOq 7W8yDju8I67K4tY8eGB3eilLe/UmMw3NLxkvIDi7q1MVTyhy7zY2w0qJuTFR0zoZiXYG N1ES2LOTGud9btG03Muzmp32nB+txM2BHEbm8WNTzJTOaYLEedNAdhOPQXB37TnljBvg L9m3lIM6WRAk163U2OVXX4k0Ju1lpgpzpHqRC0o1Bhzfp4HC6NKkh0YnBAv676lFhRDB CQv2/8hb3JyHPOgSsehKbX1SwOj5EjAjDnSfJojYO/DAzJW8Ly/7XwpzLD2uWsuCeW1Q NVUQ== X-Gm-Message-State: AOAM531QVdwg+g44TR53W439iT2IhRMAziQRVJVBcqxYtjAzISLOZzyR Dpos3BEno+Oe+3o1GAKwb5hbiQ== X-Received: by 2002:a4a:870d:0:b0:35f:7c65:1340 with SMTP id z13-20020a4a870d000000b0035f7c651340mr4597180ooh.46.1652200559980; Tue, 10 May 2022 09:35:59 -0700 (PDT) Received: from [192.168.1.128] ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id bj6-20020a056808198600b00326bab99fe5sm2726538oib.40.2022.05.10.09.35.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 May 2022 09:35:59 -0700 (PDT) Subject: Re: [PATCH 1/3] 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: <20220510030014.3842475-1-surenb@google.com> <04858a5d-98c8-69be-025f-214e4b10d502@linuxfoundation.org> From: Shuah Khan Message-ID: Date: Tue, 10 May 2022 10:35:57 -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 X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/10/22 10:29 AM, Suren Baghdasaryan wrote: > On Tue, May 10, 2022 at 8:43 AM Shuah Khan wrote: >> >> On 5/9/22 9:00 PM, Suren Baghdasaryan wrote: >>> Introduce process_mrelease syscall sanity tests. They include tests of >>> invalid pidfd and flags inputs, attempting to call process_mrelease >>> with a live process and a valid usage of process_mrelease. 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. >>> >> >> +1 on Mike's comments on improving the change log. List what is getting >> tested as opposed to describing the test code. > > I'll try to improve the description but IMHO it does describe what > it's testing - the process_mrelease syscall with valid and invalid > inputs. I could omit the implementation details if that helps. > >> >>> Signed-off-by: Suren Baghdasaryan >>> --- >>> tools/testing/selftests/vm/Makefile | 1 + >>> tools/testing/selftests/vm/mrelease_test.c | 176 +++++++++++++++++++++ >>> tools/testing/selftests/vm/run_vmtests.sh | 16 ++ >>> 3 files changed, 193 insertions(+) >>> create mode 100644 tools/testing/selftests/vm/mrelease_test.c >> >> Please update .gitignore with the new executable. > > Ack. > >> >>> >>> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile >>> index 04a49e876a46..733fccbff0ef 100644 >>> --- a/tools/testing/selftests/vm/Makefile >>> +++ b/tools/testing/selftests/vm/Makefile >>> @@ -43,6 +43,7 @@ TEST_GEN_FILES += map_populate >>> TEST_GEN_FILES += memfd_secret >>> TEST_GEN_FILES += mlock-random-test >>> TEST_GEN_FILES += mlock2-tests >>> +TEST_GEN_FILES += mrelease_test >>> TEST_GEN_FILES += mremap_dontunmap >>> TEST_GEN_FILES += mremap_test >>> TEST_GEN_FILES += on-fault-limit >>> diff --git a/tools/testing/selftests/vm/mrelease_test.c b/tools/testing/selftests/vm/mrelease_test.c >>> new file mode 100644 >>> index 000000000000..a61061bf8433 >>> --- /dev/null >>> +++ b/tools/testing/selftests/vm/mrelease_test.c >>> @@ -0,0 +1,176 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +/* >>> + * Copyright 2022 Google LLC >>> + */ >>> +#define _GNU_SOURCE >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include "util.h" >>> + >>> +static inline int pidfd_open(pid_t pid, unsigned int flags) >>> +{ >>> +#ifdef __NR_pidfd_open >>> + return syscall(__NR_pidfd_open, pid, flags); >>> +#else >>> + errno = ENOSYS; >> >> This isn't an error - this would be skip because this syscall >> isn't supported. > > Ack. > >> >>> + return -1; >>> +#endif >> >> Key off of syscall return instead of these ifdefs - same comment >> on all of the ifdefs > > Ack. I was using some other test as an example but I guess that was > not a good model. > >> >>> +} >>> + >> >> I am not seeing any reason for breaking this code up have a separate >> routine for pidfd_open(). > > I'm a bit unclear what you mean. Do you mean that userspace headers > should already define pidfd_open() and I don't need to define it? > Do you need pidfd_open() or can this be part of main? Without the ifdefs, it is really a one line code. thanks, -- Shuah