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=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 ABEC6C433E0 for ; Mon, 8 Mar 2021 22:21:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 31B836529E for ; Mon, 8 Mar 2021 22:21:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31B836529E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 81FBC8D0080; Mon, 8 Mar 2021 17:21:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A8B48D007F; Mon, 8 Mar 2021 17:21:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D4088D0080; Mon, 8 Mar 2021 17:21:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0178.hostedemail.com [216.40.44.178]) by kanga.kvack.org (Postfix) with ESMTP id 3C5AA8D007F for ; Mon, 8 Mar 2021 17:21:02 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DE58E181AEF1E for ; Mon, 8 Mar 2021 22:21:01 +0000 (UTC) X-FDA: 77898128322.02.1BDF19E Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by imf16.hostedemail.com (Postfix) with ESMTP id 3225D8019149 for ; Mon, 8 Mar 2021 22:21:01 +0000 (UTC) Received: by mail-ej1-f44.google.com with SMTP id ci14so23457073ejc.7 for ; Mon, 08 Mar 2021 14:21:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=gsZzT4mPQ2TrEl8JaekhZDeJKwM0//H/V4uDHJyM4jU=; b=jobkbkY1+hGaU1h3ss3KoQd0mPXDP7fELUfF5gKkYfGvtDum0YFEmEr2kRh/oos0mR cfC3tHLbzNMszj2eR5cRr+wi5sQILiFJ5Kc2aEp0TbUd3rt5iCkm0blOn9PgsG04bvJe C/9vNrVM3RVodn3bC49ivz0vGx1ICY7LahtgOcHeNO8yBzyjk01M0xsAoCBU6GXbkGo8 iEU6DsoUb+uArUSgVGKuPZSD+ibEnL2ZTA+zFl+8DyZF/2Dx32jKk8RS2nIZQU47F+dO aMdPtIB9BUToY6PVypfNW7Vaeg+Iyu5VybtmK2ZHo6On/aMZxUC+A0bjZQrs0wAP4BKI lTqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=gsZzT4mPQ2TrEl8JaekhZDeJKwM0//H/V4uDHJyM4jU=; b=CGawhbz7l6cL3gJz1FVbB33B3iXvumcQCr+ORo5P8mPFeaskLqrsADEpqPd+7QFryq KsKLVYatLBHTK2ZS3D7+HUmErh07CNwtyircQdaXsun/isDnu/8f9GjFnWLAAUZjoR8K mR/DfOfcFGQYcZr65kAztwMz+Hw4F0Bu/aaq1x88t6h1bVXHdjF5s7kRkc8MO/nNKNge 8UCgMjDztwJH3dot+U/bmZYh6WplytPROjZaa2RAFOD/SNI3V1kK+d4KTvYxXiNCm8N5 rB68cNKMVkRdUIhQWxjNZyScvjPcGBnc4UO/bC0SK+gkQVqnB9MHcGKPOwq9dANRiz1P 3+KQ== X-Gm-Message-State: AOAM531KXpeRx8Ac7uTZlzXrokfdlhCs+wVi9RQnj/kSBRr0400jR+v5 SlJExGpohXOydIbbjrKjR7vwGz1Ix+Ve+B+j8HU= X-Google-Smtp-Source: ABdhPJzohyWTyGkQHlvjWQEknpHziDr5CYi07PjtOGhHUF3dvjvO6XtpY5JlXQKxHQr3fPm+Yg1UckP7j9y4xPsoCn0= X-Received: by 2002:a17:906:789:: with SMTP id l9mr16788881ejc.161.1615242060200; Mon, 08 Mar 2021 14:21:00 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Yang Shi Date: Mon, 8 Mar 2021 14:20:48 -0800 Message-ID: Subject: Re: [PATCH] mm: huge_memory: a new debugfs interface for splitting THP tests. To: David Hildenbrand Cc: Zi Yan , Linux MM , Linux Kernel Mailing List , linux-kselftest@vger.kernel.org, "Kirill A . Shutemov" , Andrew Morton , Shuah Khan , John Hubbard , Sandipan Das , David Rientjes , Alex Shi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3225D8019149 X-Stat-Signature: mg5xsax8qce4ajkwughj4ttzhyjtfi8h Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf16; identity=mailfrom; envelope-from=""; helo=mail-ej1-f44.google.com; client-ip=209.85.218.44 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615242061-817666 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 Mon, Mar 8, 2021 at 1:59 PM David Hildenbrand wrote: > > > > Am 08.03.2021 um 22:25 schrieb Yang Shi : > > > > =EF=BB=BFOn Mon, Mar 8, 2021 at 12:36 PM David Hildenbrand wrote: > >> > >> > >>>> Am 08.03.2021 um 21:18 schrieb Yang Shi : > >>> > >>> =EF=BB=BFOn Mon, Mar 8, 2021 at 11:30 AM David Hildenbrand wrote: > >>>> > >>>>> On 08.03.21 20:11, Yang Shi wrote: > >>>>> On Mon, Mar 8, 2021 at 11:01 AM Zi Yan wrote: > >>>>>> > >>>>>> On 8 Mar 2021, at 13:11, David Hildenbrand wrote: > >>>>>> > >>>>>>> On 08.03.21 18:49, Zi Yan wrote: > >>>>>>>> On 8 Mar 2021, at 11:17, David Hildenbrand wrote: > >>>>>>>> > >>>>>>>>> On 08.03.21 16:22, Zi Yan wrote: > >>>>>>>>>> From: Zi Yan > >>>>>>>>>> > >>>>>>>>>> By writing ",," to > >>>>>>>>>> /split_huge_pages_in_range_pid, THPs in the process w= ith the > >>>>>>>>>> given pid and virtual address range are split. It is used to t= est > >>>>>>>>>> split_huge_page function. In addition, a selftest program is a= dded to > >>>>>>>>>> tools/testing/selftests/vm to utilize the interface by splitti= ng > >>>>>>>>>> PMD THPs and PTE-mapped THPs. > >>>>>>>>> > >>>>>>>>> Won't something like > >>>>>>>>> > >>>>>>>>> 1. MADV_HUGEPAGE > >>>>>>>>> > >>>>>>>>> 2. Access memory > >>>>>>>>> > >>>>>>>>> 3. MADV_NOHUGEPAGE > >>>>>>>>> > >>>>>>>>> Have a similar effect? What's the benefit of this? > >>>>>>>> > >>>>>>>> Thanks for checking the patch. > >>>>>>>> > >>>>>>>> No, MADV_NOHUGEPAGE just replaces VM_HUGEPAGE with VM_NOHUGEPAGE= , > >>>>>>>> nothing else will be done. > >>>>>>> > >>>>>>> Ah, okay - maybe my memory was tricking me. There is some s390x K= VM code that forces MADV_NOHUGEPAGE and force-splits everything. > >>>>>>> > >>>>>>> I do wonder, though, if this functionality would be worth a prope= r user interface (e.g., madvise), though. There might be actual benefit in = having this as a !debug interface. > >>>>>>> > >>>>>>> I think you aware of the discussion in https://lkml.kernel.org/r/= d098c392-273a-36a4-1a29-59731cdf5d3d@google.com > >>>>>> > >>>>>> Yes. Thanks for bringing this up. > >>>>>> > >>>>>>> > >>>>>>> If there will be an interface to collapse a THP -- "this memory a= rea is worth extra performance now by collapsing a THP if possible" -- it m= ight also be helpful to have the opposite functionality -- "this memory are= a is not worth a THP, rather use that somehwere else". > >>>>>>> > >>>>>>> MADV_HUGE_COLLAPSE vs. MADV_HUGE_SPLIT > >>>>>> > >>>>>> I agree that MADV_HUGE_SPLIT would be useful as the opposite of CO= LLAPSE when user might just want PAGESIZE mappings. > >>>>>> Right now, HUGE_SPLIT is implicit from mapping changes like mprote= ct or MADV_DONTNEED. > >>>>> > >>>>> IMHO, it sounds not very useful. MADV_DONTNEED would split PMD for = any > >>>>> partial THP. If the range covers the whole THP, the whole THP is go= ing > >>>>> to be freed anyway. All other places in kernel which need split THP > >>>>> have been covered. So I didn't realize any usecase from userspace f= or > >>>>> just splitting PMD to PTEs. > >>>> > >>>> THP are a limited resource. So indicating which virtual memory regio= ns > >>>> are not performance sensitive right now (e.g., cold pages in a datab= se) > >>>> and not worth a THP might be quite valuable, no? > >>> > >>> Such functionality could be achieved by MADV_COLD or MADV_PAGEOUT, > >>> right? Then a subsequent call to MADV_NOHUGEPAGE would prevent from > >>> collapsing or allocating THP for that area. > >>> > >> > >> I remember these deal with optimizing swapping. Not sure how they inte= ract with THP, especially on systems without swap - I would guess they don= =E2=80=98t as of now. > > > > Yes, MADV_PAGEOUT would just swap the THP or sub pages out. I think I > > just forgot to mention MADV_FREE which would be more suitable for this > > usecase. > > > >> > > Can you elaborate? MADV_FREE is destructive, just like a delayed MADV_DON= TNEED. How would that help here? Split THP and reclaim the memory. Then not allocate or collapse THP for this area anymore (need subsequent MADV_NOHUGEPAGE call). I'm supposed this is the main purpose of splitting a THP. And we don't have to introduce a new advise flag. Just splitting PMD to PTEs sounds less useful to me IMHO except for vma changes (i.e. mprotect, mlock, etc). > > >>>> > >>>> -- > >>>> Thanks, > >>>> > >>>> David / dhildenb > >>>> > >>> > >> > > >