Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3960639ybh; Tue, 6 Aug 2019 04:13:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/YjrYU9YNFaimj2P6MsOBESOM2Bswme+5rTMvyHGKgcuJtjr6/F4u2yxV28fjv9NLtNML X-Received: by 2002:a62:1ac9:: with SMTP id a192mr3069831pfa.260.1565090002128; Tue, 06 Aug 2019 04:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565090002; cv=none; d=google.com; s=arc-20160816; b=e8yUYB3fAqmgZHIxH3IRwNlJEWb6cMN5w5Q+ETR09ALkzuD00XeFfyJHWlLxXj0aNS LXeIgdOX6OTyK48lnjvm2bJSfny5WDpDXHotih+WDxozlA26jj3qTS5CzVFn7oEQm2Q5 eAKMdCy3nrlyI+Jp10cSD+oWUSXIAcvFkWD0AI/8VK6gQvWThBb1K5R89TwvygtXdIBk BScBj5OuyUJ065UWrUeGsjh4ruK2PfZtxMrDmGufTQMYfCzLiCnEpj2nmoohIc4OjjsL KArsNWP6hMlYjbCrKHY4HZRgfC7iQlaI/t51roSK2IBXNmF5Yxq6o3dfdvAomDyIBy1D FHtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=IVUZ3vCUTZaoNKcACCnsP7M9ScGcHtHaH8K8c7i8HGE=; b=lDLWH/vmbGaMV6OSNUlhB1ucEZwbvsZvLEKJLuIITkePISEPQ//FtUGsDVJGOnv/// 3Rj1Rl6pApB+XOfAHPETBxGNfUb/Ksw7y6JcApt2U/kiTIe7wNFCE805p0p3MTMGxa+W YD158bkb/gj4uME5ExlvnL5qaXRRNY+wkD5+acKzOJis3d80JQrOep4/Gc9PXzlaaIh5 1R1ASeZsLthP7A/Kav0mEOJm9vrp/lXxp3dTfqb3Ll1avlVg32QOUzr6639Zxm6XfKEg UEa5BJK6oJGygIc4M8GX5pbrepayyw60XcdPQQD0L7Yn02sL1+woqTTnTGm/mlFDEqTy E1Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=dzc5ZzSl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si46425932pfi.3.2019.08.06.04.13.06; Tue, 06 Aug 2019 04:13:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=dzc5ZzSl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732409AbfHFLMO (ORCPT + 99 others); Tue, 6 Aug 2019 07:12:14 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:46415 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728845AbfHFLMN (ORCPT ); Tue, 6 Aug 2019 07:12:13 -0400 Received: by mail-ed1-f66.google.com with SMTP id d4so81972663edr.13 for ; Tue, 06 Aug 2019 04:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=IVUZ3vCUTZaoNKcACCnsP7M9ScGcHtHaH8K8c7i8HGE=; b=dzc5ZzSlafWAy4fTC2ybrGXSCublaxnDUYbea0pzEG0z1VVySMMflBJVhE69+xqsxQ ESDT9/Cp7bfZI3bAbHXvis/zbWvnBL2Tt5UimOA9lpTrAdZc/C2ry9LQNpbmWXzDlqEI Uv2TeJm+Zisvbj8s0NnelXo1te8MM6RBy56cFCUBrFEBGLwOhQJX5pQ5s/Fi5zOv1P3N vxUj4YVvG++IvGchx4EZYQq6T2UHYO58Gx0S8bgicbKPJVYzkmuJrWWXexEv9O9yPDpe TLWBH3Igl7oDCOQj92KYngp53w9jybNVCctzRFInXAgzw/hzdUgcgskgBuK259f86s2x WiOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=IVUZ3vCUTZaoNKcACCnsP7M9ScGcHtHaH8K8c7i8HGE=; b=FyVoMw2gCiMnF5Z6IOJHvzFdkyXwzepZqnaFiBPkgyx5eM7r/68mSFWGh64egBwZha 1WCFUCDXy4uBuoylynU0+6cC8qPHB90AyOonx5Z/nP0lJjsO7aaU8y327Xxpz3s53/bt FUHt4R7Un7KO7xRtNLU63oDbz+OCsvX95jIQ5oNVAAHdjaRMShc1gUL/OJw72M31EUWj pCkfdnJOtSZg+ooCItfa10x7Ehu6K94C7iBHjheYyfqS0lnt5jDM57wEHNjX0aVj83M1 7HzgZjdsjftaNUDmHQe6VFViQMexbf5Zlo6UV2/5BaaqJLe5k+4+KqgXxYHTCXxyXUWy XQ9g== X-Gm-Message-State: APjAAAXgVu7B8guxLnzZmmW/U7lltqdgeTWGuxuxx/I3cV87t5GIcSP9 f6uKcEx8keMud/CcennRIuNVbw== X-Received: by 2002:a50:f98a:: with SMTP id q10mr3146171edn.267.1565089931994; Tue, 06 Aug 2019 04:12:11 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id c48sm20888241edb.10.2019.08.06.04.12.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Aug 2019 04:12:11 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id CC6D01003C7; Tue, 6 Aug 2019 14:12:10 +0300 (+03) Date: Tue, 6 Aug 2019 14:12:10 +0300 From: "Kirill A. Shutemov" To: William Kucharski Cc: LKML , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Dave Hansen , Song Liu , Bob Kasten , Mike Kravetz , Chad Mynhier , "Kirill A. Shutemov" , Johannes Weiner , Matthew Wilcox Subject: Re: [PATCH v3 2/2] mm,thp: Add experimental config option RO_EXEC_FILEMAP_HUGE_FAULT_THP Message-ID: <20190806111210.7xpmjsd4hq54vuml@box> References: <20190731082513.16957-1-william.kucharski@oracle.com> <20190731082513.16957-3-william.kucharski@oracle.com> <20190801123658.enpchkjkqt7cdkue@box> <20190805132854.5dnqkfaajmstpelm@box.shutemov.name> <19A86A16-B440-4B73-98FE-922A09484DFD@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19A86A16-B440-4B73-98FE-922A09484DFD@oracle.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 05, 2019 at 09:56:45AM -0600, William Kucharski wrote: > >> I don't really care if the start of the VMA is suitable, just whether I can map > >> the current faulting page with a THP. As far as I know, there's nothing wrong > >> with mapping all the pages before the VMA hits a properly aligned bound with > >> PAGESIZE pages and then aligned chunks in the middle with THP. > > > > You cannot map any paged as huge into wrongly aligned VMA. > > > > THP's ->index must be aligned to HPAGE_PMD_NR, so if the combination VMA's > > ->vm_start and ->vm_pgoff doesn't allow for this, you must fallback to > > mapping the page with PTEs. I don't see it handled properly here. > > It was my assumption that if say a VMA started at an address say one page > before a large page alignment, you could map that page with a PAGESIZE > page but if VMA size allowed, there was a fault on the next page, and > VMA size allowed, you could map that next range with a large page, taking > taking the approach of mapping chunks of the VMA with the largest page > possible. > > Is it that the start of the VMA must always align or that the entire VMA > must be properly aligned and a multiple of the PMD size (so you either map > with all large pages or none)? IIUC, you are missing ->vm_pgoff from the picture. The newly allocated page must land into page cache aligned on HPAGE_PMD_NR boundary. In other word you cannout have huge page with ->index, let say, 1. VMA is only suitable for at least one file-THP page if: - (vma->vm_start >> PAGE_SHIFT) % (HPAGE_PMD_NR - 1) is equal to vma->vm_pgoff % (HPAGE_PMD_NR - 1) This guarantees right alignment in the backing page cache. - *and* vma->vm_end - round_up(vma->vm_start, HPAGE_PMD_SIZE) is equal or greater than HPAGE_PMD_SIZE. Does it make sense? > > >> This is the page that content was just read to; readpage() will unlock the page > >> when it is done with I/O, but the page needs to be locked before it's inserted > >> into the page cache. > > > > Then you must to lock the page properly with lock_page(). > > > > __SetPageLocked() is fine for just allocated pages that was not exposed > > anywhere. After ->readpage() it's not the case and it's not safe to use > > __SetPageLocked() for them. > > In the current code, it's assumed it is not exposed, because a single read > of a large page that does no readahead before the page is inserted into the > cache means there are no external users of the page. You've exposed the page to the filesystem once you call ->readpage(). It *may* track the page somehow after the call. -- Kirill A. Shutemov