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 67D3EC43334 for ; Tue, 14 Jun 2022 15:04:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82F426B008C; Tue, 14 Jun 2022 11:04:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DE926B0092; Tue, 14 Jun 2022 11:04:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A6776B0093; Tue, 14 Jun 2022 11:04:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 49CD46B008C for ; Tue, 14 Jun 2022 11:04:36 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1F3B832EAC for ; Tue, 14 Jun 2022 15:04:36 +0000 (UTC) X-FDA: 79577162952.05.39525AB Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by imf15.hostedemail.com (Postfix) with ESMTP id 478F2A0081 for ; Tue, 14 Jun 2022 15:04:34 +0000 (UTC) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-30fa61b1a83so33380497b3.0 for ; Tue, 14 Jun 2022 08:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XIBvhcDPAImiME+crbgSzqcAVyK5RrJiycpGa3Gh/l4=; b=0PnOrGgpJ2T40WIGeWlqfe/7/P0mm2HsYZ5fk4ogSdBAK1xTGuH753i05BrzCE+UCI dmA7HA/rlLTTv9Qgr4XQRKnG1Vx8W0THFIv8ZKSoijZickuOFVqAuWWFe2AcF084THZk dL+oE7eq7OLxr1fKys961spGM2elS000lmIpnBOsq63uIRU3m+xgtj9XVgucb+z82JDe 7z+OOp5gWEJrkIutCK2+EXuw3UH4MK1m0QCzPTuobIno+7nI/HY9OuBqdG8AB3YRML3+ y/E1f4+21TXJpA1l1AuHaZ0u7WyUmL/t4xgbWfeJSzTRruxBdsYLz2mPXofihh6mOPUO f2ww== 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=XIBvhcDPAImiME+crbgSzqcAVyK5RrJiycpGa3Gh/l4=; b=vN13/Lgr3hpeZxQslv5EqPPVO1qoSS3iHiub3pBVgvqD5/a76CP626Wkgucql3DWGN /4Ik6QO8OWk0myoGgJI/xKiDdXcl51xwPx00gnQNYro6jMNyiF7p7pGaBxUsMl4VGg54 6UPlFmcZM1D/OXRAKovClef5xNfU6QkrQaTUahpKogLcvi8RDbSVEYQkkn+zrdOC8RVK mqEYLwSRUp1PC5JC32bE4gwk6rVDur1yuPF+5uTOYP/3xAE/OHcvAOyy5t9hRj3UYOpE DNZuZb1ob7aB7FH9Ab6gANPNghtrxgXccpGtw4euGR5gQIxNO3UotTcHBWmYzQdFu+wn zYRw== X-Gm-Message-State: AJIora/jJGpre7J30JsQJ1oOiRS2jtxiagVZdMlkc+9uShzu6gM52IWd njS9JxDtlaHtnCyW4B6s+Rzsdi+6BHzJLPPifwLLrw== X-Google-Smtp-Source: AGRyM1upO05v6xN4nB/RVN7MAJIXzcxBfDFQGXwdBAgFIaK6CPOHJDOhBFd8M+IxGlaJo5VwjhwxHgMK2SaPtM0MgcU= X-Received: by 2002:a05:690c:297:b0:30f:b472:5ff1 with SMTP id bf23-20020a05690c029700b0030fb4725ff1mr6322963ywb.31.1655219073117; Tue, 14 Jun 2022 08:04:33 -0700 (PDT) MIME-Version: 1.0 References: <20220613180858.15933-1-mike.kravetz@oracle.com> In-Reply-To: From: Muchun Song Date: Tue, 14 Jun 2022 23:03:55 +0800 Message-ID: Subject: Re: [PATCH] hugetlbfs: zero partial pages during fallocate hole punch To: Mike Kravetz Cc: LKML , Linux Memory Management List , David Hildenbrand , Naoya Horiguchi , Axel Rasmussen , Dave Hansen , Michal Hocko , Andrew Morton Content-Type: text/plain; charset="UTF-8" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655219075; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XIBvhcDPAImiME+crbgSzqcAVyK5RrJiycpGa3Gh/l4=; b=eEWlrCiago2UE62NZenlgQNF5tHsOxZDRUXs9OmK7wktln/jNFhQG27nRDewJq3IQNSXao o5x97rE7tCR0PHBAQYs9XgUBa9F0waLlNZWAaAm9xZH6eglUicnNXCL9dTgq6QuOU8GiUK aOBZVWOIpPUFakew/OYiy1bm4hDYUM8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=0PnOrGgp; spf=pass (imf15.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.128.172 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655219075; a=rsa-sha256; cv=none; b=vfI8sAXUoV/Tp8SAbCMSlVUmhRnLS1zhMHUzXHAUeCSdJBZw326NZCmioBFhnMDAMYs7mN GjOkoOvLzKQIIPH2vtFEv2tj9eOoKeyJ5h/xt6tM0oTiiI98MBMtEi+GCGBpSjA1lKlpV+ X3EFAK5Vm/WV83Q8ec8lGtrLshkep40= X-Stat-Signature: gqf994655kqyzxqqx5s4xnospjqiz55r X-Rspamd-Queue-Id: 478F2A0081 X-Rspamd-Server: rspam11 X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=0PnOrGgp; spf=pass (imf15.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.128.172 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1655219074-699684 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, Jun 14, 2022 at 4:46 AM Mike Kravetz wrote: > > Below is v2 of the patch. I was just going to change the type of start/end > hugetlbfs_zero_partial_page arguments. However, Matthew also convinced me > to do the simple folio conversion. Tested with new libhugetlbfs code. > > > From 36a18e0b07c2e189092cc2d516e8cfedcb57d191 Mon Sep 17 00:00:00 2001 > From: Mike Kravetz > Date: Mon, 13 Jun 2022 13:36:48 -0700 > Subject: [Patch v2] hugetlbfs: zero partial pages during fallocate hole punch > > hugetlbfs fallocate support was originally added with commit 70c3547e36f5 > ("hugetlbfs: add hugetlbfs_fallocate()"). Initial support only operated > on whole hugetlb pages. This makes sense for populating files as other > interfaces such as mmap and truncate require hugetlb page size alignment. > Only operating on whole hugetlb pages for the hole punch case was a > simplification and there was no compelling use case to zero partial pages. > > In a recent discussion[1] it was assumed that hugetlbfs hole punch would > zero partial hugetlb pages as that is in line with the man page > description saying 'partial filesystem blocks are zeroed'. However, > the hugetlbfs hole punch code actually does this: > > hole_start = round_up(offset, hpage_size); > hole_end = round_down(offset + len, hpage_size); > > Modify code to zero partial hugetlb pages in hole punch range. It is > possible that application code could note a change in behavior. However, > that would imply the code is passing in an unaligned range and expecting > only whole pages be removed. This is unlikely as the fallocate > documentation states the opposite. > > The current hugetlbfs fallocate hole punch behavior is tested with the > libhugetlbfs test fallocate_align[2]. This test will be updated to > validate partial page zeroing. > > [1] https://lore.kernel.org/linux-mm/20571829-9d3d-0b48-817c-b6b15565f651@redhat.com/ > [2] https://github.com/libhugetlbfs/libhugetlbfs/blob/master/tests/fallocate_align.c > > Signed-off-by: Mike Kravetz LGTM. Reviewed-by: Muchun Song Thanks.