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=-1.7 required=3.0 tests=BAYES_00,DATE_IN_PAST_12_24, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 719B9C433F5 for ; Tue, 21 Sep 2021 12:29:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 09BE561166 for ; Tue, 21 Sep 2021 12:29:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 09BE561166 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3AB386B0071; Tue, 21 Sep 2021 08:29:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 35A666B0074; Tue, 21 Sep 2021 08:29:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FC95900002; Tue, 21 Sep 2021 08:29:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 0CA916B0071 for ; Tue, 21 Sep 2021 08:29:14 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9DEF11802E61C for ; Tue, 21 Sep 2021 12:29:13 +0000 (UTC) X-FDA: 78611510586.30.93D1AD5 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by imf15.hostedemail.com (Postfix) with ESMTP id 4E7B0D0000A1 for ; Tue, 21 Sep 2021 12:29:13 +0000 (UTC) Received: by mail-ed1-f53.google.com with SMTP id g8so73840410edt.7 for ; Tue, 21 Sep 2021 05:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mbQXhXJLxiALHPsfWwZoPdiHBMG4EPZlanGbXM6TrrM=; b=baKpv2CEQS/tWKSPdcjaZsJUei28bzthQ7wJ1ePEcZ3JJlZIAULTW/3nZdMiYDLdfW +YekTDQqJPhGI2jqYzpV9EbL3mfkN740ZLQArVoqun6fNVUEkwNs9Gk5X2FrMr0RySUq TZ/Codo2apB+mxzZaYSbhyTvUDBQSrmAG8y+dn/LnpJ+e5QfuABfnyQDaxRHtSvEyNUI hunf9m0fToie6bVSTjFimIBOtvZK4McN1GCQNiarh5zpLDpHZGiKbPtWogB1hG72+O/t Kk18r47775dvNMB7qHra7yNLr8tnkAxM7Gp/9Y/lY0FlNAGTXIIVJEevNzE/k/09N7UH LwAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mbQXhXJLxiALHPsfWwZoPdiHBMG4EPZlanGbXM6TrrM=; b=fGmR+QpIe99cNKtWYfiA9EtlNfp2pCWvv0cpk3FX318mX7GrR76eGqKrwWx9vZVF1p f92TsbQsTrQcLRlekShjJwC/ERvbGrpj1mDHd2IUIiYwv5J17oPecyBKfufOS3KiTbma IdGJBgeG5nEy8HF0LBC1XK6Dk4I5DVVVHbeZobXX2C9hchg/Mdjj841zF9nR66Da9oXh b1/jrPhRXZSBEQi9it8i9ghbNNb1mlaHEfB+kgda7yLM+fBHxG4knOuFsNpH3HHRO6AU daXetXqYNc0HcV1c7iNunmRuk4tUbDUTFSpa2yP6wwWRbSgQ8V6GuhHjGQcrWl4zXGQf ohZA== X-Gm-Message-State: AOAM5339FLEK5peqCTWyIIY2yvvB2D7N6Ffe/7f3XXRSkGyo8bwrjul3 hzqcm4SfE1of18jRv+IlxnA66DREJ+LEnjsXY8E= X-Google-Smtp-Source: ABdhPJyQTWjcPqp60EDkICjrXxsIMbI22Rwm4PP/8SMqWZ4RD4eogg+BeifcA4Q7OIoQMr32lSfTIBj1sVjrtEtQsFs= X-Received: by 2002:a17:906:dbe5:: with SMTP id yd5mr33947014ejb.134.1632227342091; Tue, 21 Sep 2021 05:29:02 -0700 (PDT) MIME-Version: 1.0 References: <20210917034815.80264-1-songmuchun@bytedance.com> <20210917034815.80264-5-songmuchun@bytedance.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Tue, 21 Sep 2021 12:28:51 +1200 Message-ID: Subject: Re: [PATCH RESEND v2 4/4] selftests: vm: add a hugetlb test case To: Muchun Song Cc: Mike Kravetz , Andrew Morton , Oscar Salvador , Michal Hocko , Barry Song , David Hildenbrand , Chen Huang , "Bodeddula, Balasubramaniam" , Jonathan Corbet , Matthew Wilcox , Xiongchun duan , fam.zheng@bytedance.com, Muchun Song , Qi Zheng , linux-doc@vger.kernel.org, LKML , Linux-MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4E7B0D0000A1 X-Stat-Signature: ot9496ybtxs4148namksm7rkk8f83ckc Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=baKpv2CE; spf=pass (imf15.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.208.53 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1632227353-573498 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: On Tue, Sep 21, 2021 at 2:26 AM Muchun Song wrote: > > On Sat, Sep 18, 2021 at 1:20 PM Barry Song <21cnbao@gmail.com> wrote: > > > > On Sat, Sep 18, 2021 at 12:08 AM Muchun Song wrote: > > > > > > Since the head vmemmap page frame associated with each HugeTLB page is > > > reused, we should hide the PG_head flag of tail struct page from the > > > user. Add a tese case to check whether it is work properly. > > > > > > > TBH, I am a bit confused. I was thinking about some kernel unit tests to make > > sure those kernel APIs touched by this patchset are still working as before. > > This userspace test, while certainly useful for checking the content of page > > frames as expected, doesn't directly prove things haven't changed. > > > > In patch 1/4, a couple of APIs have the fixup for the fake head issue. > > Do you think a test like the below would be more sensible? > > 1. alloc 2MB hugeTLB > > It is done in main(). > > > 2. get each page frame > > 3. apply those APIs in each page frame > > 4. Those APIs work completely the same as before. > > Reading the flags of a page by /proc/kpageflags is done > in stable_page_flags(), which has invoked PageHead(), > PageTail(), PageCompound() and compound_head(). > If those APIs work properly, the head page must have > 15 and 17 bits set. And tail pages must have 16 and 17 > bits set but 15 unset. > > So I think check_page_flags() has done the step 2 to 4. > What do you think? yes. Thanks for your explanation. thereby, I think we just need some doc here to explain what it is checking. something like /* * pages other than the first page must be tail and shouldn't be head; * this also verifies kernel has correctly set the fake page_head to tail * while hugetlb_free_vmemmap is enabled */ + for (i = 1; i < MAP_LENGTH / PAGE_SIZE; i++) { + read(fd, &pageflags, sizeof(pageflags)); + if ((pageflags & TAIL_PAGE_FLAGS) != TAIL_PAGE_FLAGS || + (pageflags & HEAD_PAGE_FLAGS) == HEAD_PAGE_FLAGS) { + close(fd); + printf("Tail page flags (%lx) is invalid\n", pageflags); + return -1; + } + } > > Thanks. Thanks barry