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 D442CC433F5 for ; Fri, 28 Jan 2022 09:44:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 700616B0071; Fri, 28 Jan 2022 04:44:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 689136B0072; Fri, 28 Jan 2022 04:44:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52A1D6B0073; Fri, 28 Jan 2022 04:44:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0204.hostedemail.com [216.40.44.204]) by kanga.kvack.org (Postfix) with ESMTP id 429CC6B0071 for ; Fri, 28 Jan 2022 04:44:25 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 091CE951AF for ; Fri, 28 Jan 2022 09:44:25 +0000 (UTC) X-FDA: 79079210490.18.5EA642D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 80431100005 for ; Fri, 28 Jan 2022 09:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643363064; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N/1XryswyXoExyh39X8CoSuzkVzyRpWNUf/ugBJHXp0=; b=UgOWBuKxgx5KWhMzV8bUjXiwu0pB0iUPW0I/3c10RRHsuQ1BL6WNbbYjw17pM1Sg3F0567 TVwGMZ2GVJiIKCVV2y1bn+gJlOwUH7m2viNLC29+2bG2+0WhB5Eq3cJ1/XOJhKwS2yVTqQ 7fQqh2XL0P16Y3aIgPw2RsnuQdOvrw8= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-79-kywgVSrbOPG2m-DiknSonQ-1; Fri, 28 Jan 2022 04:44:22 -0500 X-MC-Unique: kywgVSrbOPG2m-DiknSonQ-1 Received: by mail-wm1-f70.google.com with SMTP id bg16-20020a05600c3c9000b0034bea12c043so5618670wmb.7 for ; Fri, 28 Jan 2022 01:44:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=N/1XryswyXoExyh39X8CoSuzkVzyRpWNUf/ugBJHXp0=; b=PdFthIeu3qEjWlD93o1L2PqOWst6Jdrz7VUe/5MA2DusGLDoo5/o1GIDPdMvA6udaO luQQ+EdTGmjBOZ5PV59TxOdGIyZSw5y+Y791MWjAvimASOCTgOlNCsb2xXDEiEw4Crsl 4LEEvQFuajagQvNKTytle4+WMlEfN8CxaccmQtdosPhzRLwCQtaItXHdER7ZXF7m4k2h FM6NKA010mF2aoOvupoMwBf0s/Ly5VpPJEAX3DfxYOfCxgwU/ovj7jNh3x2CmchoM+a9 9+Ma64H8qIV+iC6l8d0wx28n+rTODwTL223YmWSbEFcQxijpUJwArDk41/UhXRcYj9Wt LXNA== X-Gm-Message-State: AOAM531YVYGUZ7dXZp5i/K8ah5DlFgbKl+XrXvLO7/W7MARfGR57E6xr nKHMHvA8Te05/peR1+YEC43zvbpH0XupLJu32rUJAocU5ZWLQXIJ3XGSVBMv1CK092rwkkk6iMU Mlp8LoSXW5Hc= X-Received: by 2002:adf:d1ec:: with SMTP id g12mr6767054wrd.8.1643363061495; Fri, 28 Jan 2022 01:44:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8dUE3RS9JJMTdlIcqRMNDQF4r6hqZqUxrMGbTPi2btOQb6674Dqu75CkkcVlyFGa6kDwklQ== X-Received: by 2002:adf:d1ec:: with SMTP id g12mr6767033wrd.8.1643363061261; Fri, 28 Jan 2022 01:44:21 -0800 (PST) Received: from ?IPV6:2003:cb:c70e:5c00:522f:9bcd:24a0:cd70? (p200300cbc70e5c00522f9bcd24a0cd70.dip0.t-ipconnect.de. [2003:cb:c70e:5c00:522f:9bcd:24a0:cd70]) by smtp.gmail.com with ESMTPSA id l40sm1618445wms.0.2022.01.28.01.44.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jan 2022 01:44:20 -0800 (PST) Message-ID: <6505eb77-8901-00b7-49dd-4fd49eb7efe6@redhat.com> Date: Fri, 28 Jan 2022 10:44:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [RFC PATCH 0/3] Add hugetlb MADV_DONTNEED support To: Axel Rasmussen Cc: Mike Kravetz , LKML , Linux MM , Michal Hocko , Naoya Horiguchi , Peter Xu , Andrea Arcangeli , Mina Almasry , Shuah Khan , Andrew Morton References: <20220113180308.15610-1-mike.kravetz@oracle.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 80431100005 X-Stat-Signature: q6ps1hboh95bdciqpuqzj6yp1u734gny X-Rspam-User: nil Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UgOWBuKx; spf=none (imf14.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1643363064-977369 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 27.01.22 18:52, Axel Rasmussen wrote: > On Thu, Jan 27, 2022 at 3:57 AM David Hildenbrand wrote: >> >> On 13.01.22 19:03, Mike Kravetz wrote: >>> Userfaultfd selftests for hugetlb does not perform UFFD_EVENT_REMAP >>> testing. However, mremap support was recently added in commit >>> 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage backed >>> vma"). While attempting to enable mremap support in the test, it was >>> discovered that the mremap test indirectly depends on MADV_DONTNEED. >>> >>> hugetlb does not support MADV_DONTNEED. However, the only thing >>> preventing support is a check in can_madv_lru_vma(). Simply removing >>> the check will enable support. >>> >>> This is sent as a RFC because there is no existing use case calling >>> for hugetlb MADV_DONTNEED support except possibly the userfaultfd test. >>> However, adding support makes sense as it is fairly trivial and brings >>> hugetlb functionality more in line with 'normal' memory. >>> >> >> Just a note: >> >> QEMU doesn't use huge anonymous memory directly (MAP_ANON | MAP_HUGE...) >> but instead always goes either via hugetlbfs or via memfd. >> >> For MAP_PRIVATE hugetlb mappings, fallocate(FALLOC_FL_PUNCH_HOLE) seems >> to get the job done (IOW: also discards private anon pages). See the >> comments in the QEMU code below. I remember that that is somewhat >> inconsistent. For ordinary MAP_PRIVATE mapped files I remember that we >> always need fallocate(FALLOC_FL_PUNCH_HOLE) + madvise(QEMU_MADV_DONTNEED) >> to make sure >> >> a) All file pages are removed >> b) All private anon pages are removed >> >> IIRC hugetlbfs really is different in that regard, but maybe other fs >> behave similarly. >> >> That's why QEMU was able to live for now without MADV_DONTNEED support >> for hugetlbfs and most probably won't ever need it. > > Agreed, all of the production use cases I'm aware of use hugetlbfs, > not MAP_HUGE... > > But, I would say this is convenient for testing purposes. It's > slightly more convenient to not have to mount hugetlbfs / perform the > associated setup for tests. Creating a memfd is not too hard, but yes, not a single-liner. Maybe the uffd test should go via memfds for hugetlb instead. But maybe that limits the mremap functionality? No expert. > > Perhaps that's only a small motivation for enabling this, but then > again Mike's patch to do so is likewise very small. :) ... and apparently buggy :P -- Thanks, David / dhildenb