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 C3DE1C433F5 for ; Thu, 6 Jan 2022 18:26:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4271A6B0071; Thu, 6 Jan 2022 13:26:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D6D96B0072; Thu, 6 Jan 2022 13:26:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29E146B0074; Thu, 6 Jan 2022 13:26:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id 17F626B0071 for ; Thu, 6 Jan 2022 13:26:14 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C770592EA3 for ; Thu, 6 Jan 2022 18:26:13 +0000 (UTC) X-FDA: 79000691826.28.D2A80D7 Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) by imf02.hostedemail.com (Postfix) with ESMTP id 5F3E08001F for ; Thu, 6 Jan 2022 18:26:06 +0000 (UTC) Received: by mail-io1-f48.google.com with SMTP id l3so4136674iol.10 for ; Thu, 06 Jan 2022 10:26:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cEePo0A7WHWrnyag19ujaD72v/1Fwgdi8AhN3U4zmn4=; b=GyONKi3dyoK/bVjT7TNjaddSrAe2FBg0MqkBT5V1RNvfLIheuspaUVLyX2nBLBwzHC g4J36kOL48BzfrJdH+erkzTnrB4AN933FO5MSkGZeHyni0TyRsXBa4nppQLfouWscgFD Xyuka+7riIsoXfxLxDIci0wVDm9Yw+eddCZQiTCHOzFBaLLrByo98ilp1bRjeMtdAuz5 GWKNLdXt2//PqeQvBijCD5i9q2jxWm97gC8yC8GCyzZQGX66wOM8SN/TZXdns2AsPEyD xuAmCbdLMKm3f1vlsf9yWJU+91XTGe+3IRXOcbIHSidnVdME7Pb0svmTLOouWzd8jcr5 n01A== 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=cEePo0A7WHWrnyag19ujaD72v/1Fwgdi8AhN3U4zmn4=; b=zsSLkvWNMPaQEjhisbTybh8mviZ9x7jeEMu/sns5qYOWHpsqZdIiNLWAtOtNosJc/+ SCt5dbCK4mCWuprD3zzJ/9StycIIrls1I/re8iE6M4mkroUyAISqiUrZvqPKCjozDaL5 vHKEo+qoed53j+vqpfN24nXoJRGLykstj18KhJ2Bs3vFXMbYvbQGTGWNBLlZ0Qgyh4cP 8A+osGoRT3up4OPtyQuetbb2twuXdBV3x/aWQofIBft5mPl2/nKkWOwtnN07NehH6/E9 P5EPTEf9ni0ku1Cb01HJh3t6h/PTG+olUZnFk+h9ToV8S9VfYUN4E3cggVxNTum0CahK UOKA== X-Gm-Message-State: AOAM530D/IttYCTri0FJPeISt2EDADVKhUUzwoSt1ApnfZ45J+tcPuMO UCww5sj5nKCn7jPIxZ0b3n5boKZb/aiYmwwQWs6obA== X-Google-Smtp-Source: ABdhPJwpqiavJjQnNN1lJnXMEuQDSftQJ9vHHePZDWQzyx8IJ0gLnhDIsC/JAPTri4EYrttHy8cHs9V+Y/M5sOIgpaQ= X-Received: by 2002:a02:b384:: with SMTP id p4mr26804990jan.167.1641493572689; Thu, 06 Jan 2022 10:26:12 -0800 (PST) MIME-Version: 1.0 References: <20220104021729.111006-1-mike.kravetz@oracle.com> <20220105155613.45d7dcb81e19bd42deefab79@linux-foundation.org> <92ad1cf1-cd73-c3f8-44b6-6eb917b94693@oracle.com> In-Reply-To: <92ad1cf1-cd73-c3f8-44b6-6eb917b94693@oracle.com> From: Axel Rasmussen Date: Thu, 6 Jan 2022 10:25:36 -0800 Message-ID: Subject: Re: [PATCH] userfaultfd/selftests: clean up hugetlb allocation code To: Mike Kravetz Cc: Andrew Morton , LKML , Linux MM , Peter Xu , Andrea Arcangeli , Mina Almasry , Shuah Khan Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5F3E08001F X-Stat-Signature: 59sw1p5shx3b5z56jbzph4ce67g187ma Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=GyONKi3d; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf02.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.166.48 as permitted sender) smtp.mailfrom=axelrasmussen@google.com X-HE-Tag: 1641493566-840306 X-Bogosity: Ham, tests=bogofilter, spamicity=0.004883, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jan 6, 2022 at 9:43 AM Mike Kravetz wrote: > > On 1/5/22 15:56, Andrew Morton wrote: > > 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... > I agree, and also agree with Axel's comment about keeping the ternary all on > one line. However, there are examples of breaking both these conventions throughout the file. For what it's worth, I don't at all mind Andrew's way either, where the two "outcomes" of the ternary are indented a bit. Not a big deal though, whatever you'd prefer is fine. :) > > My intention here was just to clean up the mess I created with the previous > patch. As such, I would prefer to leave this patch as is. If someone really > wants this modified, I will. However, IMO if we make this one call easier > to read, we should use the same convention throughout the file. I can do that > as well, but would prefer to first try to enable using mremap with hugetlb > within the test. +1, sounds like a good plan. > -- > Mike Kravetz