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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 3D858C433E2 for ; Tue, 15 Sep 2020 17:33:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 99E192193E for ; Tue, 15 Sep 2020 17:33:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="wJA7qJJa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99E192193E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B0EA3900071; Tue, 15 Sep 2020 13:33:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABE66900066; Tue, 15 Sep 2020 13:33:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96221900071; Tue, 15 Sep 2020 13:33:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id 79EF9900066 for ; Tue, 15 Sep 2020 13:33:24 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3831B180AD807 for ; Tue, 15 Sep 2020 17:33:24 +0000 (UTC) X-FDA: 77265992328.28.girls05_530221f27113 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id E846B6C0B for ; Tue, 15 Sep 2020 17:33:23 +0000 (UTC) X-HE-Tag: girls05_530221f27113 X-Filterd-Recvd-Size: 5715 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Sep 2020 17:33:23 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id d19so1709851pld.0 for ; Tue, 15 Sep 2020 10:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=M8l6c/TjWYQRiXwPIxqfhPqbNDCVlwzZu6ART7sGA8U=; b=wJA7qJJabH1MtZuv73Nto4ArpYL8bpMpf3xBzAkp/k8HKbnVO+qNgBxVpGr0Fz0Ggd KUH/bdakO5dHORUiBJWUEiCC3O57yGwfrShO2YsEYl8X8n7zw4Tx3s+Cd5uEnn03KBrx iW+qRGl4cXUKUBcnQ3rqhtGNr7wgb44cq83D4pqDmM31tCIBVppOTUNzZ0uRaUuWN+Yd UvkfdyVoGzjnJ5jnEHZulu8IBOnYzM0iIZoCSFxiftDvpraX/xRihGAzgEbajBkm1CAo ZG+nTnkW1iTOo8PBTTwFv/WO0iuy9ZWcRS6qv6eUtgmLjjAJnAy5zwyE8a4nYq6ANJD/ +4Jg== 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=M8l6c/TjWYQRiXwPIxqfhPqbNDCVlwzZu6ART7sGA8U=; b=fAUrtgn5WYxRoMkszVMTtjwbWRcPrbFmu+V3hl2ExMwqquNXMXPUPY2N4RxGvh6pai yk+jOLEQK0g9yP7OSmMw/MW/dw/TvxJgOKynnp4Zoe9Nfhh0nzpk4E/D6KgYYVThUF5r jurUKX1KaqpvdhDsS39r2904XzRO0hr3g8EFAyjAGYpc0VeIYEg4zdL4IptALh10YvFp iasjg34vgAJSNnpJBOv0wtOov7ndYU6b31oNLV4sqXohkkxDoWX8KfIUnrC2b1z2WaTo 3/zP9rHy/2p+ipo+SXc8MpgZnGoDACZW2blBDwoS+bjhz79x6I6XNpl9hd/TZBAjYefh b/Fg== X-Gm-Message-State: AOAM530d/UtNRUwplcOnGXZqLtqVvqGi+AH0hIdeF5lVMmJGepVbOkyA y7xQ5cFK2vVYpuLWuyaH3DpGowpjZRN7KGFgSYWtBA== X-Google-Smtp-Source: ABdhPJxdqveluwOFObD/Q2IeyCwgxfBsJ6CnsJl5rU2wrD26p6QqzakCfSftmjvTx3O57U4UaQflQENKIp65BvUQEN4= X-Received: by 2002:a17:90a:fa94:: with SMTP id cu20mr388035pjb.147.1600191202144; Tue, 15 Sep 2020 10:33:22 -0700 (PDT) MIME-Version: 1.0 References: <20200915125947.26204-1-songmuchun@bytedance.com> <20200915143241.GH5449@casper.infradead.org> <20200915154213.GI5449@casper.infradead.org> In-Reply-To: <20200915154213.GI5449@casper.infradead.org> From: Muchun Song Date: Wed, 16 Sep 2020 01:32:46 +0800 Message-ID: Subject: Re: [External] Re: [RFC PATCH 00/24] mm/hugetlb: Free some vmemmap pages of hugetlb page To: Matthew Wilcox Cc: Jonathan Corbet , Mike Kravetz , Thomas Gleixner , mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, Peter Zijlstra , viro@zeniv.linux.org.uk, Andrew Morton , paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, Randy Dunlap , oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, almasrymina@google.com, David Rientjes , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: E846B6C0B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 Tue, Sep 15, 2020 at 11:42 PM Matthew Wilcox wrote: > > On Tue, Sep 15, 2020 at 11:28:01PM +0800, Muchun Song wrote: > > On Tue, Sep 15, 2020 at 10:32 PM Matthew Wilcox wrote: > > > > > > On Tue, Sep 15, 2020 at 08:59:23PM +0800, Muchun Song wrote: > > > > This patch series will free some vmemmap pages(struct page structures) > > > > associated with each hugetlbpage when preallocated to save memory. > > > > > > It would be lovely to be able to do this. Unfortunately, it's completely > > > impossible right now. Consider, for example, get_user_pages() called > > > on the fifth page of a hugetlb page. > > > > Can you elaborate on the problem? Thanks so much. > > OK, let's say you want to do a 2kB I/O to offset 0x5000 of a 2MB page > on a 4kB base page system. Today, that results in a bio_vec containing > {head+5, 0, 0x800}. Then we call page_to_phys() on that (head+5) struct > page to get the physical address of the I/O, and we turn it into a struct > scatterlist, which similarly has a reference to the page (head+5). As I know, in this case, the get_user_pages() will get a reference to the head page (head+0) before returning such that the hugetlb page can not be freed. Although get_user_pages() returns the page (head+5) and the scatterlist has a reference to the page (head+5), this patch series can handle this situation. I can not figure out where the problem is. What I missed? Thanks. > > If you're returning page (head+1) from get_user_pages(), all the > calculations will be wrong and you'll do DMA to the wrong address. > > What needs to happen is a conversion to get_user_bvecs(). That way we > can return a bvec which is {head, 0x5000, 0x800} and the calculations > will work. So that's going to involve touching a lot of device drivers. > Christoph has a start on it here: > http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/gup-bvec > > Overlapping with that is a desire to change the biovec so that it > only stores {phys_addr, length} rather than {page, offset, length}. > We're also going to have to rework the scatterlist so that it doesn't > carry a struct page either. -- Yours, Muchun