Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1337695ybf; Thu, 27 Feb 2020 09:04:39 -0800 (PST) X-Google-Smtp-Source: APXvYqytPXvpt6ZRjghfaCNKYjnh97FKLBTAEjyN0ncGxb6Y+PQ1VV+exZvS/nV513INTHnlGO5f X-Received: by 2002:a9d:19e9:: with SMTP id k96mr619895otk.68.1582823079202; Thu, 27 Feb 2020 09:04:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582823079; cv=none; d=google.com; s=arc-20160816; b=VRA4ONGcNCod+45rJnKiIZqFPOMJKdXQCDfnjcl9jQo70Jv6X14XthwvJKe8N/0JJW AINA/G8BUzzMILqaq/zo4DfBfah30F3mn6XOQxULy82Kc3bJveSgeeWribMKtyMxlUZO 8l1MtqJ6BY3e+UPHycKvr6NubFORHpJn8pbBuZXnvkwyMEIDyERFbsS7hUn1HUAD622L HXorswSo7x6Ci6d7Hus3y9HZOtErF+bFaPWbnBg1hLsq8qaxbp4HuHjYoi2LXmKOF1Ji 0yEK1dhRV69kqqBihWPlu22a3dSRs/WlVhN13l65mQNO9Uh/ue0ulAc+aWs5145jUhhw PFtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=ivG0NenvQkR8PkrDU2mBpZ9HGooYM3SCFz7DbVUGfzY=; b=n8zlxd/yQZYGL77i/5vOB+ZU/l/qybUU82zliCC5Rjuj3Wr8rVcopmkmN0xX1lV782 4ePw8t1k5Anjbb2DGsoXbdTxdYItzAnmpYFJ6lmwWkocb7VFU8Jpf7m8lFq+B+DF3jhO hhBHzCcnSNI75mDFXnLDQsuSAxGzXwQ+3PDl32wu2imweBQHCLZVS+B9LeJo0mc2gJZZ QWEpr5P7EoueUMvdmkYByQwUC4U3QZuC7sgr3UP+Ud4I2Ed6gpKUBZYvhNIu4+tiuE1v e4APpFZfkP/s9/PKlDRSy5ByoYw9LEgnh1bV1oOApdKqVWXjC3cT/2maXiB5wD0LulqB aNLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=qQ2TAJnS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b2si2389365ots.284.2020.02.27.09.04.22; Thu, 27 Feb 2020 09:04:39 -0800 (PST) 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; dkim=pass header.i=@c-s.fr header.s=mail header.b=qQ2TAJnS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729849AbgB0RDm (ORCPT + 99 others); Thu, 27 Feb 2020 12:03:42 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:62174 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729481AbgB0RDm (ORCPT ); Thu, 27 Feb 2020 12:03:42 -0500 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: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Shuah, Le 06/02/2020 à 09:42, Christophe Leroy a écrit : > 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. > > Fix read_bytes() and write_bytes() by giving them the real length. > > Also fix the call to munmap(). > > Fixes: fa7b9a805c79 ("tools/selftest/vm: allow choosing mem size and page 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(-) > > diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selftests/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)); > } > > -static void write_bytes(char *addr) > +static void write_bytes(char *addr, size_t length) > { > unsigned long i; > > - for (i = 0; i < LENGTH; i++) > + for (i = 0; i < length; i++) > *(addr + i) = (char)i; > } > > -static int read_bytes(char *addr) > +static int read_bytes(char *addr, size_t length) > { > unsigned long i; > > check_bytes(addr); > - for (i = 0; i < LENGTH; i++) > + for (i = 0; i < length; i++) > if (*(addr + i) != (char)i) { > printf("Mismatch at %lu\n", i); > return 1; > @@ -96,11 +96,11 @@ int main(int argc, char **argv) > > printf("Returned address is %p\n", addr); > check_bytes(addr); > - write_bytes(addr); > - ret = read_bytes(addr); > + write_bytes(addr, length); > + ret = read_bytes(addr, length); > > /* munmap() length of MAP_HUGETLB memory must be hugepage aligned */ > - if (munmap(addr, LENGTH)) { > + if (munmap(addr, length)) { > perror("munmap"); > exit(1); > } >