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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 9621CC6379F for ; Mon, 23 Nov 2020 15:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 430F220782 for ; Mon, 23 Nov 2020 15:32:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="iT+pGSg6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389554AbgKWPb4 (ORCPT ); Mon, 23 Nov 2020 10:31:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389536AbgKWPby (ORCPT ); Mon, 23 Nov 2020 10:31:54 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A9DC0613CF for ; Mon, 23 Nov 2020 07:31:53 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id mc24so2778884ejb.6 for ; Mon, 23 Nov 2020 07:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fIZYbFnYdwj7TViAxEdW/8HWXJPnofI2KBoUzM1Et1w=; b=iT+pGSg6Cx/G8/LTFQRRDQok0gvbqLFnc0bXOhWkbrJGuE1Ovbz2uwIfLkpTn01+qJ O8rDNv7d1DItT8Qn7hHGy6UWl4YOZfC7ferFvnenKMcRvFEzKh/EBxGDGdKTWRuvLwFw 9exeVTwUWk9tSVOT2UdJu9RPs2wgkEiTPi2rdIOOq8GO0fz0AZbZICU39aCKWuHMcEno yrFGoQKFM2atxvBSq1qrj0Ul7w8vTIfotcZVrJErR5Q9AgnWdimb8kFS49Xr7OiW7/bu S0p9FpcguwNpxRluVWWNMfGSW0mXagL7wN0mjWxILNf4GPVXTRmkvGG1HW89NYw1OLpO xvtw== 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; bh=fIZYbFnYdwj7TViAxEdW/8HWXJPnofI2KBoUzM1Et1w=; b=tJs2XWvgCwHE2f11yzUSSg46Ph/B2tb412Kl90roSPiJDPA7hGuJS7a8jR8fsXfz1z GosTjy+tGPnFd7h3tE8+FMnrB2t8AA1yOKQq9gyOcNqLtGbFDT6aVJznXeYAjOmHewMw xI038R47t5zc/dzO/qYmjR3OtvcJ0DrGdCchYWzre5fLhvh7hImsMo0/iRk+na0AixVf dEJ8ZenHqSZsByMg+jVk+r3GYC+XIKdAJqNLon/DicJQXZf1WMSnQqxJeZb7khg0k35+ TqhK8wELxEI/jhetX6m4MbYOU1jrgG6mrCFHwDlPMnNG6VHZZp9l9yI8bklTBN4EsI6s PX8Q== X-Gm-Message-State: AOAM530K33J/+f8OPRJ0BkDpKSo/4wAtIOxLszA92zkdh4a8c8E7cV7E ftdhoADvZsqTi/k+0wZodVLFASVZH9Nh/x9YmS/zXg== X-Google-Smtp-Source: ABdhPJxvfdnsQoBDcnwU9RmbQfQCopwizkSh/xOwsvjU8fVDgwdXdrtbw1GyjMWt9G9vgn4um/njtRede6eK4c/lVlY= X-Received: by 2002:a17:906:d41:: with SMTP id r1mr108385ejh.383.1606145512254; Mon, 23 Nov 2020 07:31:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Tatashin Date: Mon, 23 Nov 2020 10:31:16 -0500 Message-ID: Subject: Re: Pinning ZONE_MOVABLE pages To: David Rientjes Cc: linux-mm , Andrew Morton , Vlastimil Babka , LKML , Michal Hocko , David Hildenbrand , Oscar Salvador , Dan Williams , Sasha Levin , Tyler Hicks , Joonsoo Kim , sthemmin@microsoft.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > I've spoken with Stephen Hemminger, and he said that DPDK is moving in > > the direction of using transparent huge pages instead of HugeTLBs, > > which means that we need to allow at least anonymous, and anonymous > > transparent huge pages to come from non-movable zones on demand. > > > > I'd like to know more about this use case, ZONE_MOVABLE is typically a > great way to optimize for thp availability because, absent memory pinning, > this memory can always be defragmented. So the idea is that DPDK will now > allocate all of its thp from ZONE_NORMAL or only a small subset? Seems > like an invitation for oom kill if the sizing of ZONE_NORMAL is > insufficient. The idea is to allocate only those THP and anon pages that are long term pinned from ZONE_NORMAL, the rest can still be allocated from ZONE_MOVABLE. > > > Here is what I am proposing: > > 1. Add a new flag that is passed through pin_user_pages_* down to > > fault handlers, and allow the fault handler to allocate from a > > non-movable zone. > > > > Sample function stacks through which this info needs to be passed is this: > > > > pin_user_pages_remote(gup_flags) > > __get_user_pages_remote(gup_flags) > > __gup_longterm_locked(gup_flags) > > __get_user_pages_locked(gup_flags) > > __get_user_pages(gup_flags) > > faultin_page(gup_flags) > > Convert gup_flags into fault_flags > > handle_mm_fault(fault_flags) > > > > From handle_mm_fault(), the stack diverges into various faults, > > examples include: > > > > Transparent Huge Page > > handle_mm_fault(fault_flags) > > __handle_mm_fault(fault_flags) > > Create: struct vm_fault vmf, use fault_flags to specify correct gfp_mask > > create_huge_pmd(vmf); > > do_huge_pmd_anonymous_page(vmf); > > mm_get_huge_zero_page(vma->vm_mm); -> flag is lost, so flag from > > vmf.gfp_mask should be passed as well. > > > > There are several other similar paths in a transparent huge page, also > > there is a named path where allocation is based on filesystems, and > > the flag should be honored there as well, but it does not have to be > > added at the same time. > > > > Regular Pages > > handle_mm_fault(fault_flags) > > __handle_mm_fault(fault_flags) > > Create: struct vm_fault vmf, use fault_flags to specify correct gfp_mask > > handle_pte_fault(vmf) > > do_anonymous_page(vmf); > > page = alloc_zeroed_user_highpage_movable(vma, vmf->address); -> > > replace change this call according to gfp_mask. > > > > This would likely be useful for AMD SEV as well, which requires guest > pages to be pinned because the encryption algorithm depends on the host > physical address. This ensures that plaintext memory for two pages don't > result in the same ciphertext.