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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 6197FC433E0 for ; Sat, 30 Jan 2021 02:40:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 05C5664E11 for ; Sat, 30 Jan 2021 02:40:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05C5664E11 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6ED868D0002; Fri, 29 Jan 2021 21:40:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 69CBD8D0001; Fri, 29 Jan 2021 21:40:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 58D318D0002; Fri, 29 Jan 2021 21:40:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id 3FC4F8D0001 for ; Fri, 29 Jan 2021 21:40:55 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0304D362A for ; Sat, 30 Jan 2021 02:40:55 +0000 (UTC) X-FDA: 77760888870.02.tree87_600b382275ad Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id D0E4210097AA0 for ; Sat, 30 Jan 2021 02:40:54 +0000 (UTC) X-HE-Tag: tree87_600b382275ad X-Filterd-Recvd-Size: 5056 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Sat, 30 Jan 2021 02:40:54 +0000 (UTC) Received: by mail-pl1-f181.google.com with SMTP id e9so6426258plh.3 for ; Fri, 29 Jan 2021 18:40:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=D0pUjIq817eEpLY1erfYJdKvtkx8TmD85ooJCrZdxSA=; b=XX5mlUCXyHg3MO+/ouE/ZVknaPVTWkAI5xofVpfX1AlSTJ7ILw6x3of7jtpJBk2IPe pn2tvgP/eWNif0xUamwRP/deGhv+otrbt4txtPjsMKTeCd6D1eQf8OMivee+Tap4eg6E GqILinQT1V1YWIyNx+z7rg0bibxaE1Q3hqwuDeQxstui7fGGOnrVy1zVtiu5xeRrKm+c vl7FI0ouA5ggOHNzFpRs7CKABngg301iDyxxNiwJvuW6akLy3ayejIZd2f8HvwAxYeai Po/+Mmdridw44bVUtfxvHOBwuzhRzMd3O0yjYYDY3SLD6n+kMX/YWN9I9bcWFBqscVSS 1vIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=D0pUjIq817eEpLY1erfYJdKvtkx8TmD85ooJCrZdxSA=; b=Serbd0C/2pNXBPMyvHvg0DPGcCTwFnRu6+ZPv4C7WLPpaj90y08cvn6x8t/5UGB1GP qMq8JYEEBozvejMJMsc/WBI0MBjIXP//i0huauYNpbMpB6KFGa5o2+2uWSbBqUvEK3yl FBXTzDJAppGyWiRZQsg/Cr9uQdhm8bTrcoRbVlx0ekguIvIrcd6/8BIXkNzgsI9gMsQR bWkPCsaqEk+97N78IBEic+kYvofK17dQRSHI3bKczNEmK+d12q3yTo5gc8wbH4kAYWMT NGIiJ4BIrKxfNtVGqcRVlUC5xr5oW2F0noqn+sM+aitPLYdQ6/fDhGeWWr/YRxjKM4WW 3Grw== X-Gm-Message-State: AOAM531ZBLXRwxiwiS/JZNJOMn5/r2Czc7ycgNBriurwgGsSl1snyh4k +RRDkM/HSNZ71Fi/6kTebf8= X-Google-Smtp-Source: ABdhPJwNOC95sbrGpa94svCb4hQvVgw051zTbfysO4+X9FQ4KcBxlv+ZI2KWYah7oynz7IYZJAHWNw== X-Received: by 2002:a17:903:183:b029:e1:1057:a4c7 with SMTP id z3-20020a1709030183b02900e11057a4c7mr7302912plg.31.1611974453208; Fri, 29 Jan 2021 18:40:53 -0800 (PST) Received: from google.com ([2620:15c:211:201:b81c:be0c:d615:b5bb]) by smtp.gmail.com with ESMTPSA id d11sm8710138pjz.29.2021.01.29.18.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 18:40:52 -0800 (PST) Date: Fri, 29 Jan 2021 18:40:50 -0800 From: Minchan Kim To: Matthew Wilcox Cc: hughd@google.com, kirill@shutemov.name, linux-mm Subject: Re: THP handling with driver compound page on fault Message-ID: References: <20210130010002.GE308988@casper.infradead.org> <20210130012844.GF308988@casper.infradead.org> <20210130020911.GG308988@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210130020911.GG308988@casper.infradead.org> 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 Sat, Jan 30, 2021 at 02:09:11AM +0000, Matthew Wilcox wrote: > On Fri, Jan 29, 2021 at 05:49:11PM -0800, Minchan Kim wrote: > > On Sat, Jan 30, 2021 at 01:28:44AM +0000, Matthew Wilcox wrote: > > > On Fri, Jan 29, 2021 at 05:22:24PM -0800, Minchan Kim wrote: > > > > Hi Mattew, > > > > > > > > On Sat, Jan 30, 2021 at 01:00:02AM +0000, Matthew Wilcox wrote: > > > > > On Fri, Jan 29, 2021 at 04:13:07PM -0800, Minchan Kim wrote: > > > > > > A custom driver overrides (vm_operations_struct.fault) and map their > > > > > > compound page(__GFP_COMP) to page table on userprocess on demand. > > > > > > > > > > You're looking to backport: > > > > > > > > > > commit d01ac3c35214ce362f50cada37cb7bab8c801896 > > > > > Author: Matthew Wilcox (Oracle) > > > > > Date: Thu Oct 15 20:05:26 2020 -0700 > > > > > > > > > > mm/memory: remove page fault assumption of compound page size > > > > > > > > > > > > > I guess you meant the check below. > > > > > > > > if (compound_order(page) != HPAGE_PMD_ORDER) > > > > > > > > What happens if driver allcoated HPAGE_PMD_ORDER size? > > > > > > ... then it should be fine to map it with a PMD entry? > > > > I don't think so because following logic assumes it's THP page, > > for example, page_add_file_rmap, count_vm_event(THP_FILE_MAPPED) > > in do_set_pmd. > > > > Isn't it bug? > > Clearly nobody's actually tested it, but I think in principle, if a > device driver returns a PMD sized page (and it's appropriately aligned), > it should be mapped with a PMD entry. Okay, then you mean d01ac3c35214ce362f50cada37cb7bab8c801896 will fix the corruption for every-order driver compound page mapping. I have no idea it's worth to solve THP_FILE_MAPPED misaccounting problem but it doesn't matter for my case, at least. Thanks for the quick answer, Matthew.