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 X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A83AC35677 for ; Thu, 27 Feb 2020 17:09:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3ABA24697 for ; Thu, 27 Feb 2020 17:09:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=c-s.fr header.i=@c-s.fr header.b="qQ2TAJnS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3ABA24697 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=c-s.fr Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8C4966B0005; Thu, 27 Feb 2020 12:09:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8753B6B0006; Thu, 27 Feb 2020 12:09:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78A966B0007; Thu, 27 Feb 2020 12:09:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0028.hostedemail.com [216.40.44.28]) by kanga.kvack.org (Postfix) with ESMTP id 5F5306B0005 for ; Thu, 27 Feb 2020 12:09:19 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2B57F1F219 for ; Thu, 27 Feb 2020 17:09:19 +0000 (UTC) X-FDA: 76536542838.24.word20_339c38a67c48 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 9BBC310F15 for ; Thu, 27 Feb 2020 17:03:44 +0000 (UTC) X-HE-Tag: word20_339c38a67c48 X-Filterd-Recvd-Size: 5000 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Thu, 27 Feb 2020 17:03:42 +0000 (UTC) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48SzXB3jH9z9tyX0; Thu, 27 Feb 2020 18:03:38 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=qQ2TAJnS; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id lT4opiy4Qpqi; Thu, 27 Feb 2020 18:03:38 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48SzXB28lmz9tyWv; Thu, 27 Feb 2020 18:03:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1582823018; bh=ivG0NenvQkR8PkrDU2mBpZ9HGooYM3SCFz7DbVUGfzY=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=qQ2TAJnSG5rWsee88j6nad+tuJ9WtixEjEin3eXlX7opv2cv4hq6hZXkvm5CACMiz LVQrY7R8aSu+JuZ1LAiykc8H95XuwDKbOiBPLQrTBRTecf2/Mzv2lkuzxnkm96QnDW q5FMafTk76Ro//h6tgtJQwVa+No5DSBj82q9iu40= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DCF7C8B880; Thu, 27 Feb 2020 18:03:39 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id fKAvznOpv8mR; Thu, 27 Feb 2020 18:03:39 +0100 (CET) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 82BF18B799; Thu, 27 Feb 2020 18:03:38 +0100 (CET) Subject: Re: [PATCH] selftests/vm: Fix map_hugetlb length used for testing read and write From: Christophe Leroy To: Shuah Khan Cc: Michael Ellerman , linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: <9a404a13c871c4bd0ba9ede68f69a1225180dd7e.1580978385.git.christophe.leroy@c-s.fr> Message-ID: <797ec84e-7257-d97a-5c13-9a9d9f1f650a@c-s.fr> Date: Thu, 27 Feb 2020 18:03:20 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <9a404a13c871c4bd0ba9ede68f69a1225180dd7e.1580978385.git.christophe.leroy@c-s.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: quoted-printable 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: Shuah, Le 06/02/2020 =C3=A0 09:42, Christophe Leroy a =C3=A9crit=C2=A0: > Commit fa7b9a805c79 ("tools/selftest/vm: allow choosing mem size and > page size in map_hugetlb") added the possibility to change the size > of memory mapped for the test, but left the read and write test using > the default value. This is unnoticed when mapping a length greater > than the default one, but segfaults otherwise. >=20 > Fix read_bytes() and write_bytes() by giving them the real length. >=20 > Also fix the call to munmap(). >=20 > Fixes: fa7b9a805c79 ("tools/selftest/vm: allow choosing mem size and pa= ge size in map_hugetlb") > Cc: stable@vger.kernel.org Can you also consider this one for next rc ? Thanks Christophe > Signed-off-by: Christophe Leroy > --- > tools/testing/selftests/vm/map_hugetlb.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) >=20 > diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/s= elftests/vm/map_hugetlb.c > index 5a2d7b8efc40..6af951900aa3 100644 > --- a/tools/testing/selftests/vm/map_hugetlb.c > +++ b/tools/testing/selftests/vm/map_hugetlb.c > @@ -45,20 +45,20 @@ static void check_bytes(char *addr) > printf("First hex is %x\n", *((unsigned int *)addr)); > } > =20 > -static void write_bytes(char *addr) > +static void write_bytes(char *addr, size_t length) > { > unsigned long i; > =20 > - for (i =3D 0; i < LENGTH; i++) > + for (i =3D 0; i < length; i++) > *(addr + i) =3D (char)i; > } > =20 > -static int read_bytes(char *addr) > +static int read_bytes(char *addr, size_t length) > { > unsigned long i; > =20 > check_bytes(addr); > - for (i =3D 0; i < LENGTH; i++) > + for (i =3D 0; i < length; i++) > if (*(addr + i) !=3D (char)i) { > printf("Mismatch at %lu\n", i); > return 1; > @@ -96,11 +96,11 @@ int main(int argc, char **argv) > =20 > printf("Returned address is %p\n", addr); > check_bytes(addr); > - write_bytes(addr); > - ret =3D read_bytes(addr); > + write_bytes(addr, length); > + ret =3D read_bytes(addr, length); > =20 > /* munmap() length of MAP_HUGETLB memory must be hugepage aligned */ > - if (munmap(addr, LENGTH)) { > + if (munmap(addr, length)) { > perror("munmap"); > exit(1); > } >=20