Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2074916pxb; Mon, 8 Mar 2021 13:28:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+B80EPDsR77yNHouDBs/IjD1cmUaBy5qKaCeXCn8BNmNapSioDX0EMcvaMxo7EZxU8Gmg X-Received: by 2002:aa7:d74d:: with SMTP id a13mr576115eds.199.1615238883295; Mon, 08 Mar 2021 13:28:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615238883; cv=none; d=google.com; s=arc-20160816; b=LviO1+S7eHmej+FoGBEkBQtMbkUlk3WQJbPYIYHnR3GwUdeigUXgVuF72SQZ6nlUSn LUyC4A6VDXscG0mf8C+GdguniCnkypC0RHoEGpuGW0mTlavrfFYo9j8h+TQllMIGXSS2 Myi2IVgkRf0UbrXaVGpozQFqFOwTcTGI+2OaY5yxH1tk4+vQy347UcRwO5wUrDhgVTwj AEtTG7cJh5CG0bpf5dYAIawcPHI1cy+gLpjz8IJbnH+wt3TTY6OVFMCk6wbLgkzlxen1 f0P3AkOhzBwKQzgNV28iHqL9/Ii3XSLxwEL2pTFmL8TYn+ghF4MMvK5vuQBj+Px3Kk0s BEZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=qOsKysHmPp2aVhNaoAMyp4YZeDW1D1UH7Hy8PXT8Ies=; b=amUU/bZd9n1Gnsflww8oOJ7E+p6YNx/L6D0aOb3GPAHy+T+W3rCXM5oRN+5DvBmore yCfPYv3EOW7pXK3LHWalLPccSUVT9JyMnjwlkhbTUkzAKnEaor1CgNbF+F2HZ8hzciMx osvPZ3D7LSa09WJ1R6jL5S3OZ/CUHjelUnfXZTOWd5Hz4JPFeWpYYuKZLJ1pe8hLdEer hp84ajYb/oLQHGReGSJAjckY31YoI+X30ehx5uuxHqKfQhCOesMeipwakqkHk+5tgbYe Vs1MTOWdx9CySVfzGs+WW8beAGLf6niAUTxhpkD2Tb2bZMhI9EVWCt0tovLbEWOISWKU ApQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fSsrlhxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j20si7427535ejy.7.2021.03.08.13.27.40; Mon, 08 Mar 2021 13:28:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fSsrlhxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230063AbhCHVZV (ORCPT + 99 others); Mon, 8 Mar 2021 16:25:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbhCHVZV (ORCPT ); Mon, 8 Mar 2021 16:25:21 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC238C06174A; Mon, 8 Mar 2021 13:25:20 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id l12so16923088edt.3; Mon, 08 Mar 2021 13:25:20 -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=qOsKysHmPp2aVhNaoAMyp4YZeDW1D1UH7Hy8PXT8Ies=; b=fSsrlhxOBFqSDG74RFsuvBiXnKrnpyYRjWU02QXSEfajja6RCbjkh6fjcG6etzsLQi CXEqoxFgQxDpDDCcjHogfn70fUoImQDbt6iPH0Fe+UzU2zLbEiabLPDjpv5ROlrw82im xYSd14uc/CDxMcsgPSbZm2xMHr7/gtAXEUAkEDWIRsJjfzVzL1p+BJfnL8pOu/EMvvRs Pz+maOFPsGl5fQa0iqVUqMHZYs7CYnWMYQV9PNzrjg+8TPZf2F1C1m68Hyp0MGQnixAU El6YCIOCEZ3DSuqe4CJ2eqKDz9nvlxftGJZAyp3fBKr31BfZ8eozcbv7Z0HoHsBlsydR gPtQ== 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=qOsKysHmPp2aVhNaoAMyp4YZeDW1D1UH7Hy8PXT8Ies=; b=FnIOz1drk4OIep1X7t/TF75SG8200pbkzQNVLbi29uN0vser7nQsfi+X+YZ9XBRYO1 EpmO+ZYD1SM7JLTRneSBYeNxJGjYKwFeCtbgEyKSV8XUYatyve1cphgPwg+CyPP02UHt z4Usaf7xafPJcLkk3fSuHzTBe4fQL372kGSAdD0DE6W51vUIMAM83hw44PmfczmjZhpV dQopqTnqCQf1KvTVGCJIKhtYv8xApHhP2xe7sn5w25fgiNzXGTHPil/08t2uimpNRdq2 tmAYKVlW5Iu2qxpqbx2X2pVuR6QqwooiIa5kZK/s8rni74TmnaSsiz5u/T1srDpOejUi KFSw== X-Gm-Message-State: AOAM533Y+wsYZx3WHFuc7p66Sm3zU8ppggw3SoO56dTNQV/xcNfDq2xb Op/Vrixu3oVuRs0z09iA5FwVqBdrVKoTVz7eVgY= X-Received: by 2002:aa7:de82:: with SMTP id j2mr534611edv.313.1615238719519; Mon, 08 Mar 2021 13:25:19 -0800 (PST) MIME-Version: 1.0 References: <44C62A78-4B37-445D-A9F7-25D1A412A802@redhat.com> In-Reply-To: <44C62A78-4B37-445D-A9F7-25D1A412A802@redhat.com> From: Yang Shi Date: Mon, 8 Mar 2021 13:25:07 -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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 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 wit= h the > >>>>>>>> given pid and virtual address range are split. It is used to tes= t > >>>>>>>> split_huge_page function. In addition, a selftest program is add= ed to > >>>>>>>> tools/testing/selftests/vm to utilize the interface by splitting > >>>>>>>> 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 KVM= code that forces MADV_NOHUGEPAGE and force-splits everything. > >>>>> > >>>>> I do wonder, though, if this functionality would be worth a proper = user interface (e.g., madvise), though. There might be actual benefit in ha= ving this as a !debug interface. > >>>>> > >>>>> I think you aware of the discussion in https://lkml.kernel.org/r/d0= 98c392-273a-36a4-1a29-59731cdf5d3d@google.com > >>>> > >>>> Yes. Thanks for bringing this up. > >>>> > >>>>> > >>>>> If there will be an interface to collapse a THP -- "this memory are= a is worth extra performance now by collapsing a THP if possible" -- it mig= ht also be helpful to have the opposite functionality -- "this memory area = 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 COLL= APSE when user might just want PAGESIZE mappings. > >>>> Right now, HUGE_SPLIT is implicit from mapping changes like mprotect= or MADV_DONTNEED. > >>> > >>> IMHO, it sounds not very useful. MADV_DONTNEED would split PMD for an= y > >>> partial THP. If the range covers the whole THP, the whole THP is goin= g > >>> 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 for > >>> just splitting PMD to PTEs. > >> > >> THP are a limited resource. So indicating which virtual memory regions > >> are not performance sensitive right now (e.g., cold pages in a databse= ) > >> 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 interac= t 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. > > >> > >> -- > >> Thanks, > >> > >> David / dhildenb > >> > > >