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 559ACC5321D for ; Mon, 26 Aug 2024 14:18:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C96406B008A; Mon, 26 Aug 2024 10:18:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C45F26B008C; Mon, 26 Aug 2024 10:18:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEC796B0092; Mon, 26 Aug 2024 10:18:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8E6D56B008A for ; Mon, 26 Aug 2024 10:18:31 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 20703C115B for ; Mon, 26 Aug 2024 14:18:31 +0000 (UTC) X-FDA: 82494602022.25.2985B5F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id DA76518002B for ; Mon, 26 Aug 2024 14:18:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VoKa45RH; spf=pass (imf24.hostedemail.com: domain of mcasquer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mcasquer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724681865; a=rsa-sha256; cv=none; b=0gr7Lk+2eWeIVcZEHsn36/5fxAerb+KTGahY9NWpCJfjZi18IejxuWG/4InnD7CmC/5Ysp O5hn6zP9Ut7FvF+AUlA7/5Y+S/s81u9Emm4znUqYsDb6+OmaeT/qUo6C3Fgv151KvodtW8 5rciP25VN8Ikc1N70vLxWZj1vz7wa38= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VoKa45RH; spf=pass (imf24.hostedemail.com: domain of mcasquer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mcasquer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724681865; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=epejtgmZ6P+cnuAUKGDMtJ1Zom6Sbo3EnXXkkIT7RGo=; b=BBm7nKQp50Dr7Vzvl9bLJLxadLc1NgRJG8CGxmP4xS1ZfSASHrc9zUiePNR3f6FjEhY4yM F7JQmO132yvcRbfqiA/noHJHwKi+FRzYAT5YiLmMffHIQMgMueeaD92fMpEE6noZgY7Bhb NaANUtARvOaYbp2jVx+LByNcfS4siQE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724681908; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=epejtgmZ6P+cnuAUKGDMtJ1Zom6Sbo3EnXXkkIT7RGo=; b=VoKa45RHq/slnEHCsJ8xl76SjLR1KxMW+ikkJZpkjGnUOVtMHUiqfde/P8YbiLWX2iMGWe q9jUQjgvZubSo3tQf2Cx9q7pm6XxwoAOhA44/YT6lNQkBzfZukEb1kNPvf5+hxP8JVqFXb Ro3D/n43eIzLkqDCx8Lv0qcNxhWk5A4= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-9HWaSuReNmyJE0VltjG39A-1; Mon, 26 Aug 2024 10:18:24 -0400 X-MC-Unique: 9HWaSuReNmyJE0VltjG39A-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2f508065daeso12106131fa.0 for ; Mon, 26 Aug 2024 07:18:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724681903; x=1725286703; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=epejtgmZ6P+cnuAUKGDMtJ1Zom6Sbo3EnXXkkIT7RGo=; b=RxXfBl44I7zlDTNbeIlwWCY+uL487Kt3mvmmU+t9h6k1JRLPioIyS+hUH/i540x0ZD xTr8bip13o31az1g606tAGqVDbHgvNIeNyXd/+h1TqfP6VO/PQeWKFk3PgB56BxnfzV0 x/qJaU9vYpu9OCAt3oxHaEEkl2i9ZBaUq2M5wuevPFEX2Pd0RT+hv5NGwcU0yQFSvCZU 5eCMJLlNQ9Qxbh4QaFR+W4nSt7Qg59I245tWpeca66DL5QjWA5/gj628PERoIfgrAE4g 2lztkn9gKX9/c7mMSpsAq0aIQENsEqD4W6j04x2wsOBZH1QwCBgLstg2xNXbTv+Jh47R 4vHw== X-Forwarded-Encrypted: i=1; AJvYcCUZ4uN1CIl0RcbmKsouZ60rKM9VnnjSFRRq0Ey7H/KgMFDMrlnq/5iNiMoUy02csFCQrq/kFnFuyA==@kvack.org X-Gm-Message-State: AOJu0Yyg/R1CXLvKRO3hwBJUyiHZQKeSW1flwZfYyARvsZUspYLvsyXa /Y8r4N0itkIDHCOuhXVjLkOh+RBRxWQpQVU0F6mTRKrPCEuAkaZV0wc5bgmfpXxSVFqN3MEmPSg kLxNDRtOVXMvCkAnSmEev5jz4mcO/yymOyrHySQ1/nWe2L99bUQ1T/U+XNo2QqxHb1QBdxI6BlM pUoi6yBGsCzaggF4cFyGVpEQQ= X-Received: by 2002:a2e:a543:0:b0:2f1:6108:3f00 with SMTP id 38308e7fff4ca-2f4f4743664mr26815251fa.0.1724681903016; Mon, 26 Aug 2024 07:18:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAZYY5jdtpgdgXWZ7zNtGCuEM+zlPT/j+eVCg3rTngipWDx2Xz2dHTuB+p5Bj7qVhnNUS2aqr4ZKB7Tk3FRc4= X-Received: by 2002:a2e:a543:0:b0:2f1:6108:3f00 with SMTP id 38308e7fff4ca-2f4f4743664mr26815101fa.0.1724681902401; Mon, 26 Aug 2024 07:18:22 -0700 (PDT) MIME-Version: 1.0 References: <20240821123115.2068812-1-david@redhat.com> In-Reply-To: From: Mario Casquero Date: Mon, 26 Aug 2024 16:18:11 +0200 Message-ID: Subject: Re: [PATCH v1] selftests/mm: fix charge_reserved_hugetlb.sh test To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Andrew Morton , Shuah Khan , Muchun Song , Mina Almasry X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: wseqwj8ohx6a4kyxykxj4a88khf883et X-Rspamd-Queue-Id: DA76518002B X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724681908-732861 X-HE-Meta: U2FsdGVkX1/711Sl1TNnrBd5I8fxP/B/dTjs4Ut7mIC7/Y/eWS5I/IT5cibr8Htz2L+EkQ85hdUKN8nO8tvQNR9zI5PlIir6FM5HaE6vwmWVBiuZI8uV5r40oyWKNC16rFxFKLQ6hh1NkWdQjH4a+e0G0GFgMBbzrssGPbxjtu00Xw+IUMfq43TlC3AAiJhTju93gDjEPI6BiBmioDCYju6y+s7jY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FZ9Gipje18udEjSRrygdDXKmrOKi4JuFYdNJZmw4wo7UFBQhDGhofJyCZYwLz/czNjVvN2qoZiUagIkZHXd0Ea824qa+AxGFZR0dA= 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: List-Subscribe: List-Unsubscribe: Missing the hyphen :) Tested-by: Mario Casquero On Mon, Aug 26, 2024 at 4:16=E2=80=AFPM Mario Casquero wrote: > > This patch has been successfully tested. All hugetlb kernel selftests pas= s now. > # SUMMARY: PASS=3D12 SKIP=3D0 FAIL=3D0 > > Tested by: Mario Casquero > > > On Wed, Aug 21, 2024 at 2:31=E2=80=AFPM David Hildenbrand wrote: > > > > Currently, running the charge_reserved_hugetlb.sh selftest we can > > sometimes observe something like: > > > > $ ./charge_reserved_hugetlb.sh -cgroup-v2 > > ... > > write_result is 0 > > After write: > > hugetlb_usage=3D0 > > reserved_usage=3D10485760 > > killing write_to_hugetlbfs > > Received 2. > > Deleting the memory > > Detach failure: Invalid argument > > umount: /mnt/huge: target is busy. > > > > Both cases are issues in the test. > > > > While the unmount error seems to be racy, it will make the test fail: > > $ ./run_vmtests.sh -t hugetlb > > ... > > # [FAIL] > > not ok 10 charge_reserved_hugetlb.sh -cgroup-v2 # exit=3D32 > > > > The issue is that we are not waiting for the write_to_hugetlbfs process > > to quit. So it might still have a hugetlbfs file open, about which > > umount is not happy. Fix that by making "killall" wait for the process > > to quit. > > > > The other error ("Detach failure: Invalid argument") does not seem to > > result in a test error, but is misleading. Turns out write_to_hugetlbfs= .c > > unconditionally tries to cleanup using shmdt(), even when we only > > mmap()'ed a hugetlb file. Even worse, shmaddr is never even set for the > > SHM case. Fix that as well. > > > > With this change it seems to work as expected. > > > > Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation te= sts") > > Reported-by: Mario Casquero > > Cc: Andrew Morton > > Cc: Shuah Khan > > Cc: Muchun Song > > Cc: Mina Almasry > > Signed-off-by: David Hildenbrand > > --- > > .../selftests/mm/charge_reserved_hugetlb.sh | 2 +- > > .../testing/selftests/mm/write_to_hugetlbfs.c | 21 +++++++++++-------- > > 2 files changed, 13 insertions(+), 10 deletions(-) > > > > diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/to= ols/testing/selftests/mm/charge_reserved_hugetlb.sh > > index d680c00d2853a..67df7b47087f0 100755 > > --- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh > > +++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh > > @@ -254,7 +254,7 @@ function cleanup_hugetlb_memory() { > > local cgroup=3D"$1" > > if [[ "$(pgrep -f write_to_hugetlbfs)" !=3D "" ]]; then > > echo killing write_to_hugetlbfs > > - killall -2 write_to_hugetlbfs > > + killall -2 --wait write_to_hugetlbfs > > wait_for_hugetlb_memory_to_get_depleted $cgroup > > fi > > set -e > > diff --git a/tools/testing/selftests/mm/write_to_hugetlbfs.c b/tools/te= sting/selftests/mm/write_to_hugetlbfs.c > > index 6a2caba19ee1d..1289d311efd70 100644 > > --- a/tools/testing/selftests/mm/write_to_hugetlbfs.c > > +++ b/tools/testing/selftests/mm/write_to_hugetlbfs.c > > @@ -28,7 +28,7 @@ enum method { > > > > /* Global variables. */ > > static const char *self; > > -static char *shmaddr; > > +static int *shmaddr; > > static int shmid; > > > > /* > > @@ -47,15 +47,17 @@ void sig_handler(int signo) > > { > > printf("Received %d.\n", signo); > > if (signo =3D=3D SIGINT) { > > - printf("Deleting the memory\n"); > > - if (shmdt((const void *)shmaddr) !=3D 0) { > > - perror("Detach failure"); > > + if (shmaddr) { > > + printf("Deleting the memory\n"); > > + if (shmdt((const void *)shmaddr) !=3D 0) { > > + perror("Detach failure"); > > + shmctl(shmid, IPC_RMID, NULL); > > + exit(4); > > + } > > + > > shmctl(shmid, IPC_RMID, NULL); > > - exit(4); > > + printf("Done deleting the memory\n"); > > } > > - > > - shmctl(shmid, IPC_RMID, NULL); > > - printf("Done deleting the memory\n"); > > } > > exit(2); > > } > > @@ -211,7 +213,8 @@ int main(int argc, char **argv) > > shmctl(shmid, IPC_RMID, NULL); > > exit(2); > > } > > - printf("shmaddr: %p\n", ptr); > > + shmaddr =3D ptr; > > + printf("shmaddr: %p\n", shmaddr); > > > > break; > > default: > > -- > > 2.46.0 > >