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 X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 872EDC433DB for ; Thu, 18 Feb 2021 13:52:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DA09D64E5F for ; Thu, 18 Feb 2021 13:52:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA09D64E5F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2AEC06B0006; Thu, 18 Feb 2021 08:52:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 25F626B006C; Thu, 18 Feb 2021 08:52:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 175206B006E; Thu, 18 Feb 2021 08:52:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id 011D66B0006 for ; Thu, 18 Feb 2021 08:52:56 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B9D4D181AF5D0 for ; Thu, 18 Feb 2021 13:52:56 +0000 (UTC) X-FDA: 77831529552.26.67905A6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf02.hostedemail.com (Postfix) with ESMTP id BC5CA4080F44 for ; Thu, 18 Feb 2021 13:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613656375; 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=SMl80mulEM7CQ/sWAw4ntJBldXaWIego0BbdzCYFKpA=; b=dVYPC76DVXGPrtKNYVFW/wu3TuImsuuAhwRa9guWxyCC3LmU+/V3i1+Rq3p9gxkcE411ou 0Pvdwe2ZvWY9h7adtnQw2pbscSbrk9UaTYF5ZztbHiiVGA+qzSDPB1Cg+i3XLPvMc51YdZ f/7MRECsUpV9v3Rg/Qh4Dk0bkJOA+eg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-UEHfHncfPauxdax8GZ6qlg-1; Thu, 18 Feb 2021 08:52:53 -0500 X-MC-Unique: UEHfHncfPauxdax8GZ6qlg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27CD79128E; Thu, 18 Feb 2021 13:52:51 +0000 (UTC) Received: from [10.36.114.59] (ovpn-114-59.ams2.redhat.com [10.36.114.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id D502D6F98F; Thu, 18 Feb 2021 13:52:36 +0000 (UTC) Subject: Re: [RFC] Hugepage collapse in process context To: Vlastimil Babka , Michal Hocko , David Rientjes Cc: Alex Shi , Hugh Dickins , Andrea Arcangeli , "Kirill A. Shutemov" , Song Liu , Matthew Wilcox , Minchan Kim , Chris Kennelly , linux-mm@kvack.org, linux-api@vger.kernel.org References: <0b51a213-650e-7801-b6ed-9545466c15db@suse.cz> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <600ee57f-d839-d402-fb0f-e9f350114dce@redhat.com> Date: Thu, 18 Feb 2021 14:52:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <0b51a213-650e-7801-b6ed-9545466c15db@suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BC5CA4080F44 X-Stat-Signature: 4a6ie85zz5m67nhd9rdgf73ingqp7m95 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf02; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613656367-732796 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 18.02.21 14:43, Vlastimil Babka wrote: > On 2/17/21 9:21 AM, Michal Hocko wrote: >> [Cc linux-api] >> >> On Tue 16-02-21 20:24:16, David Rientjes wrote: >>> Hi everybody, >>> >>> Khugepaged is slow by default, it scans at most 4096 pages every 10s. >>> That's normally fine as a system-wide setting, but some applications would >>> benefit from a more aggressive approach (as long as they are willing to >>> pay for it). >>> >>> Instead of adding priorities for eligible ranges of memory to khugepaged, >>> temporarily speeding khugepaged up for the whole system, or sharding its >>> work for memory belonging to a certain process, one approach would be to >>> allow userspace to induce hugepage collapse. >>> >>> The benefit to this approach would be that this is done in process context >>> so its cpu is charged to the process that is inducing the collapse. >>> Khugepaged is not involved. >> >> Yes, this makes a lot of sense to me. >> >>> Idea was to allow userspace to induce hugepage collapse through the new >>> process_madvise() call. This allows us to collapse hugepages on behalf of >>> current or another process for a vectored set of ranges. >> >> Yes, madvise sounds like a good fit for the purpose. > > Agreed on both points. > >>> This could be done through a new process_madvise() mode *or* it could be a >>> flag to MADV_HUGEPAGE since process_madvise() allows for a flag parameter >>> to be passed. For example, MADV_F_SYNC. >> >> Would this MADV_F_SYNC be applicable to other madvise modes? Most >> existing madvise modes do not seem to make much sense. We can argue that >> MADV_PAGEOUT would guarantee the range was indeed reclaimed but I am not >> sure we want to provide such a strong semantic because it can limit >> future reclaim optimizations. >> >> To me MADV_HUGEPAGE_COLLAPSE sounds like the easiest way forward. > > I guess in the old madvise(2) we could create a new combo of MADV_HUGEPAGE | > MADV_WILLNEED with this semantic? But you are probably more interested in > process_madvise() anyway. There the new flag would make more sense. But there's > also David H.'s proposal for MADV_POPULATE and there might be benefit in > considering both at the same time? Should e.g. MADV_POPULATE with MADV_HUGEPAGE > have the collapse semantics? But would MADV_POPULATE be added to > process_madvise() as well? Just thinking out loud so we don't end up with more > flags than necessary, it's already confusing enough as it is. > Note that madvise() eats only a single value, not flags. Combinations as you describe are not possible. Something MADV_HUGEPAGE_COLLAPSE make sense to me that does not need the mmap lock in write and does not modify the actual VMA, only a mapping. -- Thanks, David / dhildenb