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 04223C27C4F for ; Thu, 13 Jun 2024 08:13:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BE0B6B0098; Thu, 13 Jun 2024 04:13:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76CB96B0099; Thu, 13 Jun 2024 04:13:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65B966B009B; Thu, 13 Jun 2024 04:13:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 475266B0098 for ; Thu, 13 Jun 2024 04:13:34 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6B9D3141951 for ; Thu, 13 Jun 2024 08:13:33 +0000 (UTC) X-FDA: 82225151106.12.99C9AFB Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP id 6E94840009 for ; Thu, 13 Jun 2024 08:13:31 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=STjcwns+; spf=none (imf12.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718266410; a=rsa-sha256; cv=none; b=omrwhTwfIDBg1wVMXXuWwCOIJ9jO23NDOfiBXjF3G+aoakTa9KpBRZ4pB4hxjT9sND8RYU ee/XbsKy0NkWZ2oyzg5zrWeMRu+tbD/0HdJFbEreBHpW5oR+vBwCrSKQNpRJGO2A/4CCaE UBvuQJD8HVYeEVt7rchxJmv6TB92Osc= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=STjcwns+; spf=none (imf12.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718266410; h=from:from:sender: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=4tDm3WgVInHNS/5kjhxvZFPWNjbm8XCD62VosdI0ZqA=; b=tm6Gg2KHbzNfjKgIcSiGLVCqYjBwS1wiDvzhgnlyNvA9oMGcj3hgzHU27IB5w3V9MKIrMc XX7boNqDWS3fQM9tKZjysf6RdwofGplUHZIpPiD8c5jjdiDP0oTuKVVSf2vXMLdFR4bHqE MkBNYRSH/FuLlHns+F6iMkzazpLe1wI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=4tDm3WgVInHNS/5kjhxvZFPWNjbm8XCD62VosdI0ZqA=; b=STjcwns+MX7WwUCdz1orWSM+Oj MUeT6jui1SDjdDuqrURypebhDqwJ6MHl5cPNgkhTystt12Ki3pzS9YNSwjojRp283glskdoCp0weI shnQ30LJJ9r2GvGAMVL76bISmjFRxokLlIMzj7kYvGtalND19sljJCVCYpb+oK8hBKIQ1F7s5wxQB xMJn61quhpGFEbCg51p1+WP++ulC67UsqdQiarG6+jB9yhNQGyw2FsQc/IQZX0Q7v7v6wI3xo3fMg tJSOwzsezRp8vr209sbjUexBdi8O0Q87zzQHdqSAveDjMo6N0O0gHWNlR/DWIkGJdOBVixOK6ApcG p7WyiSXQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHfaE-0000000FdVc-3F1j; Thu, 13 Jun 2024 08:13:22 +0000 Date: Thu, 13 Jun 2024 01:13:22 -0700 From: Luis Chamberlain To: David Hildenbrand Cc: Matthew Wilcox , Hugh Dickins , yang@os.amperecomputing.com, linmiaohe@huawei.com, muchun.song@linux.dev, osalvador@suse.de, "Pankaj Raghav (Samsung)" , david@fromorbit.com, djwong@kernel.org, chandan.babu@oracle.com, brauner@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, hare@suse.de, linux-kernel@vger.kernel.org, Zi Yan , linux-xfs@vger.kernel.org, p.raghav@samsung.com, linux-fsdevel@vger.kernel.org, hch@lst.de, gost.dev@samsung.com, cl@os.amperecomputing.com, john.g.garry@oracle.com Subject: Re: [PATCH v7 06/11] filemap: cap PTE range to be created to allowed zero fill in folio_map_range() Message-ID: References: <20240607145902.1137853-1-kernel@pankajraghav.com> <20240607145902.1137853-7-kernel@pankajraghav.com> <818f69fa-9dc7-4ca0-b3ab-a667cd1fb16d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <818f69fa-9dc7-4ca0-b3ab-a667cd1fb16d@redhat.com> X-Stat-Signature: rtjjtugh5pzsogjynnjnpeipxyj456m1 X-Rspamd-Queue-Id: 6E94840009 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1718266411-681232 X-HE-Meta: U2FsdGVkX19GRaG3QhaMxeW6lOyxe0gaOwfLgbKsPY0V+0q+rY33HQ6++gT8yzVxAcCtlyDaML9oHCdMYIkb53b37h/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XcuzAqiegtkwBb/6xUgdhSoMht8SODr5IgKzeimHKTDyvzs0i4iugjJ4efKFpdYCf51viWeEzVlO4VLjUMpGQmt2aAD2qSO5BoTBp4UleLMKx7MGgi366vd4oWmjOivfHyMPXRtIEMbbsSMb5H92bza3MRljhzMjYNc0ve0wdxJboRS07xJwOtTcgsuAXCqMRfFDuNuKFILqHVPNUPwvGeE9M7wUx7Ba5ldaL6ZIXrzwbWn8Zl4pJX5gHq4JChKe434er7IeFfcPHmFIfyNuEQSVkmV2TkOCG8f0CZjVHg9y/RdQ1iROuxD6fTpcAs3hkSzOCAHrU2XmZf 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: On Thu, Jun 13, 2024 at 10:07:15AM +0200, David Hildenbrand wrote: > On 13.06.24 09:57, Luis Chamberlain wrote: > > On Wed, Jun 12, 2024 at 08:08:15PM +0100, Matthew Wilcox wrote: > > > On Fri, Jun 07, 2024 at 02:58:57PM +0000, Pankaj Raghav (Samsung) wrote: > > > > From: Pankaj Raghav > > > > > > > > Usually the page cache does not extend beyond the size of the inode, > > > > therefore, no PTEs are created for folios that extend beyond the size. > > > > > > > > But with LBS support, we might extend page cache beyond the size of the > > > > inode as we need to guarantee folios of minimum order. Cap the PTE range > > > > to be created for the page cache up to the max allowed zero-fill file > > > > end, which is aligned to the PAGE_SIZE. > > > > > > I think this is slightly misleading because we might well zero-fill > > > to the end of the folio. The issue is that we're supposed to SIGBUS > > > if userspace accesses pages which lie entirely beyond the end of this > > > file. Can you rephrase this? > > > > > > (from mmap(2)) > > > SIGBUS Attempted access to a page of the buffer that lies beyond the end > > > of the mapped file. For an explanation of the treatment of the > > > bytes in the page that corresponds to the end of a mapped file > > > that is not a multiple of the page size, see NOTES. > > > > > > > > > The code is good though. > > > > > > Reviewed-by: Matthew Wilcox (Oracle) > > > > Since I've been curating the respective fstests test to test for this > > POSIX corner case [0] I wanted to enable the test for tmpfs instead of > > skipping it as I originally had it, and that meant also realizing mmap(2) > > specifically says this now: > > > > Huge page (Huge TLB) mappings > > Confusion alert: this likely talks about hugetlb (MAP_HUGETLB), not THP and > friends. > > So it might not be required for below changes. Thanks, I had to ask as we're dusting off this little obscure corner of the universe. Reason I ask, is the test fails for tmpfs with huge pages, and this patch fixes it, but it got me wondering the above applies also to tmpfs with huge pages. Luis