Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4642289pxf; Tue, 30 Mar 2021 13:03:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpu9Ebav2hb6ybzWWKIVJy9+Ah7EdYTfL4R0UH0fE2l+7i5pqxUvho53Dco+KoLTrGlM3M X-Received: by 2002:a05:6402:b21:: with SMTP id bo1mr35169864edb.368.1617134594634; Tue, 30 Mar 2021 13:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617134594; cv=none; d=google.com; s=arc-20160816; b=iRY9UJJOpEc/Ozed95QH57h2LXb3hvLpkPkLooxzHa/cfbhWmDwAZXedoC8mZCnhUP Tw2HfND2R1GcSnJqxh8ag2L4wLqaHJ8UbE6KSdCi9B7gQhmBWgB2j7WdmrTsJZnXL0NS 8j+voLstub/OY4jF8/GSEvMdmucGwQU9JTwCMjwFliYfjsWZYPxNqYMt6U5teKmqGx1c Nc9ptTuvLrG5tOQV3W5+e8WX4qpUUpHxO21Rv/3n9tOQrVWlIW5Xn5gL6AXGjua8g4vN XPLyNJlyC6yDArSE3Kbgob6+klF33RY0xK/ABOUbirmJRF/JCk9QpZ0ndyoP0lUYKnQQ 0+vQ== 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=iUQpi+sJY96M0oTRItdYRMKHG3+VxUz+t6vY8dGmO+U=; b=gOATLHlG0lH7VGYVkZ70T78qbDhHHaj6ND4S+UlBM06icoFzVlnyHdTY2HcOW1mgCO mkEh491+aTaYEMLGln7HuYJ3Zmquvu115j9wCeRtlkSo+kYP2kqhKGB4dozbNU0K6yxW mpDRinYzPBIOP1b7qKlokvIrQpAzX+/oNy/KKKOXTbPyMBEDKiwb7AK326QK9Culs5uq MGa0AFFeXIaVrrSL55P3wovgt/zW4C1QD0OqP8Nsq+iqE2eJ3hvRGYJ+km7+2Y0nrQnp 2SrYcGKbODJQtP8U1rYDEHtQ9ip/7pSHXKA6m7P4FDs1ojyQNzayd49nlq7J+CSg8zj6 HNlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oeUZ5mND; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e8si1830edq.351.2021.03.30.13.02.51; Tue, 30 Mar 2021 13:03:14 -0700 (PDT) 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=@google.com header.s=20161025 header.b=oeUZ5mND; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233322AbhC3UBn (ORCPT + 99 others); Tue, 30 Mar 2021 16:01:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233298AbhC3UBM (ORCPT ); Tue, 30 Mar 2021 16:01:12 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9E72C061762 for ; Tue, 30 Mar 2021 13:01:11 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id 15so21335219ljj.0 for ; Tue, 30 Mar 2021 13:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=iUQpi+sJY96M0oTRItdYRMKHG3+VxUz+t6vY8dGmO+U=; b=oeUZ5mND0ZbBb92my2vpif9MOmzQpXmPHa6ESdE9DoEgmJ+f4n7aaHY2hH2cLOqBU5 lVvw3oI5Hub03dWw0BPaeUYp7WteB8Z+ilsGDG0uvhCNa0btjGOj4iqHeXlIKIh2AqM3 HMOgo3bj2JQddAe6BV9FPcySj7NAFx4dwvGTQHf3a30b44vc8Vpc/9QkLiUDRuMchM0k zrxWJ4f6fkYlf0ube1r+3OFxfH05Nf0v9t/1zeHq26DG7zOuAjK/m1t0GVOiC3DM5hjt iSsfM4b2LKDhF+tTotxIuu8AzYxnN/Tv5JkVaPgMIgPArL+cQSbK9IzJQvEkhuszTrYy FdpA== 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=iUQpi+sJY96M0oTRItdYRMKHG3+VxUz+t6vY8dGmO+U=; b=jsD0QJfAEgITXpR/CgqCOMBZKh6iLHcT5PVWXguhITtGoYLF7Oy6GkUsPV5orqhls3 Jpfn+rrbbEhVNs0PpMVLXjGX20HXUClAPZhaMkjG5RqVKGra+Yf0cgJHRmDqE8+F3lRM EbaxCmTl9oudEATKQlPXg294/PMfVsvtnSXK7jIWJWNpJ7CQksKb6h+yd4DarAihJkhK lg7XujjlXVX9BDZmeauDv7ExR7rjtWWFq/nBCJZeiqBQqqhkmyDqlPD1HzXBzz3Olgk0 Md8634/pKj2j3ARlpzeBxwq/jtjxUpIrIyV0EYmsK7sPm25hYP0iJxhxJdSaIyVzrgeO /RTQ== X-Gm-Message-State: AOAM531q3UZOxDgcrQeZpdkmKjolEQz3KzaLfKqAXO4Uf8fOtDPbxxuF LSzHavdmUvSmnUtgGmc21gl4wyRgsplLAluBRGExNQ== X-Received: by 2002:a2e:8196:: with SMTP id e22mr22326561ljg.398.1617134470053; Tue, 30 Mar 2021 13:01:10 -0700 (PDT) MIME-Version: 1.0 References: <20210322215823.962758-1-cfijalkovich@google.com> <2E59E29C-E04D-417C-9B2B-7F0F7D5E43EA@fb.com> In-Reply-To: <2E59E29C-E04D-417C-9B2B-7F0F7D5E43EA@fb.com> From: Collin Fijalkovich Date: Tue, 30 Mar 2021 13:00:59 -0700 Message-ID: Subject: Re: [PATCH] mm, thp: Relax the VM_DENYWRITE constraint on file-backed THPs To: Song Liu Cc: Song Liu , Suren Baghdasaryan , Hridya Valsaraju , Kalesh Singh , Hugh Dickins , Tim Murray , Alexander Viro , Andrew Morton , Linux-Fsdevel , open list , Linux-MM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There will be an immediate performance hit when the file is opened for write, as its associated pages are removed from the page cache. While the writer is present there will be the usual overhead of using 4kB pages instead of THPs, but there should not be an additional penalty. It is problematic if a file is repeatedly opened for write, as it will need to refault each time. - Collin On Sun, Mar 28, 2021 at 9:45 AM Song Liu wrote: > > > > > On Mar 23, 2021, at 10:13 AM, Collin Fijalkovich wrote: > > > > Question: when we use this on shared library, the library is still > > writable. When the > > shared library is opened for write, these pages will refault in as 4kB > > pages, right? > > > > That's correct, while a file is opened for write it will refault into 4= kB pages and block use of THPs. Once all writers complete (i_writecount <= =3D0), the file can fault into THPs again and khugepaged can collapse exist= ing page ranges provided that it can successfully allocate new huge pages. > > Will it be a problem if a slow writer (say a slow scp) writes to the > shared library while the shared library is in use? > > Thanks, > Song > > > > > From, > > Collin > > > > On Mon, Mar 22, 2021 at 4:55 PM Song Liu wrote: > > On Mon, Mar 22, 2021 at 3:00 PM Collin Fijalkovich > > wrote: > > > > > > Transparent huge pages are supported for read-only non-shmem filesyst= ems, > > > but are only used for vmas with VM_DENYWRITE. This condition ensures = that > > > file THPs are protected from writes while an application is running > > > (ETXTBSY). Any existing file THPs are then dropped from the page cac= he > > > when a file is opened for write in do_dentry_open(). Since sys_mmap > > > ignores MAP_DENYWRITE, this constrains the use of file THPs to vmas > > > produced by execve(). > > > > > > Systems that make heavy use of shared libraries (e.g. Android) are un= able > > > to apply VM_DENYWRITE through the dynamic linker, preventing them fro= m > > > benefiting from the resultant reduced contention on the TLB. > > > > > > This patch reduces the constraint on file THPs allowing use with any > > > executable mapping from a file not opened for write (see > > > inode_is_open_for_write()). It also introduces additional conditions = to > > > ensure that files opened for write will never be backed by file THPs. > > > > Thanks for working on this. We could also use this in many data center > > workloads. > > > > Question: when we use this on shared library, the library is still > > writable. When the > > shared library is opened for write, these pages will refault in as 4kB > > pages, right? > > > > Thanks, > > Song >