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 8C856C433FE for ; Wed, 5 Jan 2022 23:56:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7C156B0080; Wed, 5 Jan 2022 18:56:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D2A076B0081; Wed, 5 Jan 2022 18:56:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF2486B0082; Wed, 5 Jan 2022 18:56:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id AC3A66B0080 for ; Wed, 5 Jan 2022 18:56:20 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6D84995299 for ; Wed, 5 Jan 2022 23:56:20 +0000 (UTC) X-FDA: 78997894920.28.EE3FCD3 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf07.hostedemail.com (Postfix) with ESMTP id 02D8F40006 for ; Wed, 5 Jan 2022 23:56:19 +0000 (UTC) Received: from mail.kernel.org (unknown [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7A93FB81069; Wed, 5 Jan 2022 23:56:18 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id A3F6860E8D; Wed, 5 Jan 2022 23:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1641426976; bh=FjLhYNPIXm5K8QpAnWqx2tru94VewUjMx/27feOHfMc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ci17J0QjY8Jt5WTe3ENSwbU33iK8tOQckXIsqDmb027A0xU83rz73D3EIU719TpXa tPvwvhH761GP6ufANWz3bLdXQl110YlJVBbjnnuV5oJAgfzJ2drE+lxxhiWBVtUfuO tk0h4xq3Y3qFQLo7OtyWmOUso83OC1MRlVjE8BQg= Date: Wed, 5 Jan 2022 15:56:13 -0800 From: Andrew Morton To: Axel Rasmussen Cc: Mike Kravetz , LKML , Linux MM , Peter Xu , Andrea Arcangeli , Mina Almasry , Shuah Khan Subject: Re: [PATCH] userfaultfd/selftests: clean up hugetlb allocation code Message-Id: <20220105155613.45d7dcb81e19bd42deefab79@linux-foundation.org> In-Reply-To: References: <20220104021729.111006-1-mike.kravetz@oracle.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 02D8F40006 X-Stat-Signature: qucef97596a5eoqpzikkjwud8w9tp8m4 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=ci17J0Qj; spf=pass (imf07.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1641426979-29116 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 4 Jan 2022 14:35:34 -0800 Axel Rasmussen wrote: > On Mon, Jan 3, 2022 at 6:17 PM Mike Kravetz wrote: > > > > The message for commit f5c73297181c ("userfaultfd/selftests: fix hugetlb > > area allocations") says there is no need to create a hugetlb file in the > > non-shared testing case. However, the commit did not actually change > > the code to prevent creation of the file. > > > > While it is technically true that there is no need to create and use a > > hugetlb file in the case of non-shared-testing, it is useful. This is > > because 'hole punching' of a hugetlb file has the potentially incorrect > > side effect of also removing pages from private mappings. The > > userfaultfd test relies on this side effect for removing pages from the > > destination buffer during rounds of stress testing. > > > > Remove the incomplete code that was added to deal with no hugetlb file. > > Just keep the code that prevents reserves from being created for the > > destination area. > > > > *alloc_area = mmap(NULL, nr_pages * page_size, PROT_READ | PROT_WRITE, > > - map_shared ? MAP_SHARED : > > - MAP_PRIVATE | MAP_HUGETLB | > > + (map_shared ? MAP_SHARED : MAP_PRIVATE) | > > + MAP_HUGETLB | > > (*alloc_area == area_src ? 0 : MAP_NORESERVE), > > - huge_fd, > > - *alloc_area == area_src ? 0 : nr_pages * page_size); > > + huge_fd, *alloc_area == area_src ? 0 : > > + nr_pages * page_size); > > Sorry to nitpick, but I think it was slightly more readable when the > ternary was all on one line. When you have that many arguments I think it's clearer to put one per line, viz. *alloc_area = mmap(NULL, nr_pages * page_size, PROT_READ | PROT_WRITE, (map_shared ? MAP_SHARED : MAP_PRIVATE) | MAP_HUGETLB | (*alloc_area == area_src ? 0 : MAP_NORESERVE), huge_fd, *alloc_area == area_src ? 0 : nr_pages * page_size); But whatever...