Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1755894imm; Sat, 29 Sep 2018 03:28:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV63yU9N/4DwmAgBkArMleG/sKKUbhkDmNzWxdCCF11LGwfBec1/KJD53TkgJiiA7YfAjld7X X-Received: by 2002:aa7:8751:: with SMTP id g17-v6mr2528936pfo.250.1538216928721; Sat, 29 Sep 2018 03:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538216928; cv=none; d=google.com; s=arc-20160816; b=mUtWPWLNQPEQLn4Qtj7bhXxdmPbe7/StY60bEiJhcXtycjFwp6GhlcahDN+wEOsAhi PEYPeJkypikT/lE8Y8F7tevEE5xPzOFqZQFzYxoB/Xc1FOP/TJZooarmFvQMLw83bcBn 0e/tow+3ioNPydYonEk+lNfACD73izOGa7pfAx2uKTfz1ewgX0vA2JNYI5dGA8PmjI78 S6Xvhj7hQfzevf7WZ+A7YsCYESCA01OsjbRPUUs7motqz9oGXsSyTBv4AOqFQnLOA1wu Vedw0f2mTvr3sptKpR0ShUyccXyjx+S1r4GmbvPHK4vEIRlQZs1qKEBNiMFIFrPUcCyV btnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date; bh=FOIBR5aY0FXlrZ0+ErQdQ8qWaXG8PvEOwBIKdBbrCS0=; b=QpLVKIcUCaCl7DmMcHcDW7LgpSuY1RGEtGMjDaJHRmRL1O2a+NWduhRsBsHBVrTpgz TOZRgmGkZEaNr8LrLvByoW59OV3k34p9dbZ9oQmuVAm9Qf//c3nvZ4X1iq//zZiGaJyo AumZeu6aKncXgXoxCFtmgZuQbjbulspHRdSJuGTiIk0BhrRn6F2np+0+wRNLv7+P4/F3 7CeXYK4ecMHvl/MJbk3g0pGCSQb7Jpg70LlpLZigdXUBja4kyQaNi5MI/MwHK9bYXzOy dQZiOPVgL9AMJEdvtMGpqC3P1nLh0PO/jMYW6lCuKhW2KnZgelK2Fe7wyB48pldBq4UZ YxdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z20-v6si6973471pgj.466.2018.09.29.03.28.32; Sat, 29 Sep 2018 03:28:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727881AbeI2Q4S (ORCPT + 99 others); Sat, 29 Sep 2018 12:56:18 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39552 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727786AbeI2Q4S (ORCPT ); Sat, 29 Sep 2018 12:56:18 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8TAPHH8137361 for ; Sat, 29 Sep 2018 06:28:24 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mt4q5mjqu-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 29 Sep 2018 06:28:24 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 29 Sep 2018 11:28:21 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sat, 29 Sep 2018 11:28:16 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8TASFTm63635696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 29 Sep 2018 10:28:15 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21A794C040; Sat, 29 Sep 2018 13:27:58 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D95D24C044; Sat, 29 Sep 2018 13:27:56 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.207.35]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Sat, 29 Sep 2018 13:27:56 +0100 (BST) Date: Sat, 29 Sep 2018 13:28:12 +0300 From: Mike Rapoport To: Peter Xu Cc: linux-kernel@vger.kernel.org, Shuah Khan , Jerome Glisse , Mike Kravetz , linux-mm@kvack.org, Zi Yan , "Kirill A . Shutemov" , linux-kselftest@vger.kernel.org, Shaohua Li , Andrea Arcangeli , "Dr . David Alan Gilbert" , Andrew Morton Subject: Re: [PATCH 1/3] userfaultfd: selftest: cleanup help messages References: <20180929084311.15600-1-peterx@redhat.com> <20180929084311.15600-2-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180929084311.15600-2-peterx@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 18092910-0020-0000-0000-000002CD2547 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18092910-0021-0000-0000-0000211B5969 Message-Id: <20180929102811.GA6429@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-29_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809290110 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 29, 2018 at 04:43:09PM +0800, Peter Xu wrote: > Firstly, the help in the comment region is obsolete, now we support > three parameters. Since at it, change it and move it into the help > message of the program. > > Also, the help messages dumped here and there is obsolete too. Use a > single usage() helper. > > Signed-off-by: Peter Xu Small comment below, otherwise Acked-by: Mike Rapoport > --- > tools/testing/selftests/vm/userfaultfd.c | 44 ++++++++++++++---------- > 1 file changed, 26 insertions(+), 18 deletions(-) > > diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c > index 7b8171e3128a..2a84adaf8cf8 100644 > --- a/tools/testing/selftests/vm/userfaultfd.c > +++ b/tools/testing/selftests/vm/userfaultfd.c > @@ -34,18 +34,6 @@ > * per-CPU threads 1 by triggering userfaults inside > * pthread_mutex_lock will also verify the atomicity of the memory > * transfer (UFFDIO_COPY). > - * > - * The program takes two parameters: the amounts of physical memory in > - * megabytes (MiB) of the area and the number of bounces to execute. > - * > - * # 100MiB 99999 bounces > - * ./userfaultfd 100 99999 > - * > - * # 1GiB 99 bounces > - * ./userfaultfd 1000 99 > - * > - * # 10MiB-~6GiB 999 bounces, continue forever unless an error triggers > - * while ./userfaultfd $[RANDOM % 6000 + 10] 999; do true; done > */ > > #define _GNU_SOURCE > @@ -115,6 +103,28 @@ pthread_attr_t attr; > ~(unsigned long)(sizeof(unsigned long long) \ > - 1))) > > +const char *examples = > + "# 100MiB 99999 bounces\n" > + "./userfaultfd anon 100 99999\n" > + "\n" > + "# 1GiB 99 bounces\n" > + "./userfaultfd anon 1000 99\n" > + "\n" > + "# 10MiB-~6GiB 999 bounces, continue forever unless an error triggers\n" > + "while ./userfaultfd anon $[RANDOM % 6000 + 10] 999; do true; done\n" > + "\n"; While at it, can you please update the examples to include other test types? > + > +static void usage(void) > +{ > + fprintf(stderr, "\nUsage: ./userfaultfd " > + "[hugetlbfs_file]\n\n"); > + fprintf(stderr, "Supported : anon, hugetlb, " > + "hugetlb_shared, shmem\n\n"); > + fprintf(stderr, "Examples:\n\n"); > + fprintf(stderr, examples); > + exit(1); > +} > + > static int anon_release_pages(char *rel_area) > { > int ret = 0; > @@ -1272,8 +1282,7 @@ static void sigalrm(int sig) > int main(int argc, char **argv) > { > if (argc < 4) > - fprintf(stderr, "Usage: [hugetlbfs_file]\n"), > - exit(1); > + usage(); > > if (signal(SIGALRM, sigalrm) == SIG_ERR) > fprintf(stderr, "failed to arm SIGALRM"), exit(1); > @@ -1286,20 +1295,19 @@ int main(int argc, char **argv) > nr_cpus; > if (!nr_pages_per_cpu) { > fprintf(stderr, "invalid MiB\n"); > - fprintf(stderr, "Usage: \n"), exit(1); > + usage(); > } > > bounces = atoi(argv[3]); > if (bounces <= 0) { > fprintf(stderr, "invalid bounces\n"); > - fprintf(stderr, "Usage: \n"), exit(1); > + usage(); > } > nr_pages = nr_pages_per_cpu * nr_cpus; > > if (test_type == TEST_HUGETLB) { > if (argc < 5) > - fprintf(stderr, "Usage: hugetlb \n"), > - exit(1); > + usage(); > huge_fd = open(argv[4], O_CREAT | O_RDWR, 0755); > if (huge_fd < 0) { > fprintf(stderr, "Open of %s failed", argv[3]); > -- > 2.17.1 > -- Sincerely yours, Mike.