Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp304130rdb; Sat, 19 Aug 2023 02:23:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkibaNVZhM9Y3sLGuxcYXSuBq3NLDFmJdicSj8NYtkAjhTcVC0rSbdXngQTDpKGp5rCJHi X-Received: by 2002:a6b:c90e:0:b0:787:16ec:2699 with SMTP id z14-20020a6bc90e000000b0078716ec2699mr2744298iof.2.1692437038882; Sat, 19 Aug 2023 02:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692437038; cv=none; d=google.com; s=arc-20160816; b=k5jJReJVFDUVD9Cc4SuZONtsitGVWYizWC9CkmkaWAw2FRHrcIllxxEd9zNxAAvIzI KQkG6dnr9tEpo0xNuSJYDEiMbR2o4jR8IUFtYYVfhi/CN2VaXDiIOVc4zP3Se/+L2+K7 dZL36/LghKEe4Ajx31lkG51CXEGbc3XEA5Z1eWh+gqpT3mzAF4cm7RviM77cnpbv3lKr z93DsThD0dTRlqP6iCTqYR7lcWMOZbQcPTKADrmdwANerfJJtUGUi7EFdq53BYfhG71h 374fkCICMFiCIssT/TAZOENfFHB+IIwqstTGFxNVRYYckYlFWhPmbmNl06iB7jh0DB9W uuuQ== 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=IdiC6L+abnI7yMaQpQLGz5ktCkS2ADhtdZrEzDNVLG8=; fh=SrqHBijV+3aphmGFh35qJpGel3zmCil9uyuChM6JcsU=; b=KpASkmZbGp8Ej43BhbKkS9opuOeE4ZtlegUws7o7MaerMy1szRNYTgbOhNBSqUs+0O u8rSU53Z8+zmbSCeXN82gsBR6xrTXcU8mq6GZcSfOYwsbFn0gl27A/R57j30BxBsSkrM gWh8/prEgxuv46LtuZkWY/GvW1FlhXN4wgn2jdiNDFt92Mx3slGErWJP4YfbKVwtNaj9 kNZCpfUHeV0GcA9zQ9uLL5o/mBaC5tfn1i3+h6/Cuw+HcwPx677jqwCecylhaikcfCMk gaZzEwQa9mIAiHOqGSrq3kRLu7a0Uerzhg5z6HAxH726QZfEAIII6y7nE/A3aGsIxoIP C1Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="Qm/4X2lt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pf16-20020a17090b1d9000b00268414272cbsi5226864pjb.75.2023.08.19.02.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="Qm/4X2lt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0CAAD255E1; Sat, 19 Aug 2023 01:27:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355186AbjHQVOH (ORCPT + 99 others); Thu, 17 Aug 2023 17:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355176AbjHQVNe (ORCPT ); Thu, 17 Aug 2023 17:13:34 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46BC7358D for ; Thu, 17 Aug 2023 14:13:33 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fe32ec7201so8785e9.1 for ; Thu, 17 Aug 2023 14:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692306812; x=1692911612; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IdiC6L+abnI7yMaQpQLGz5ktCkS2ADhtdZrEzDNVLG8=; b=Qm/4X2ltNOuNAlJpd409MjBCzYTuAx+2qoDtpxCxzf4qxsBEFhk+xlVSwfp+UDzQVg TuOi0yv36C+6OqcwDFx4i7jOZ3QDF7MkwcEHjWg9lgb6qFy8a2K2KArY+pE3Ta15CpBJ QkrG/caC24wzjH4CgQqPCSnrwX8G2GBFz0lkslHFWaLXwZzWjvOfa1hbK7YX2HP9izU2 EznBqyWlCTBjZ0/hqNFeRfw9Oh0KxNknVNLyZ4RgUCveVF14OeDQDk+T/io7eS3nmXcu 2XU0oKikG1lcqu62bSJtbAzcmJ4QJopQ55+YXAz7OMjcWZB6babYixP87i+K26Id8e6S 6oHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692306812; x=1692911612; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IdiC6L+abnI7yMaQpQLGz5ktCkS2ADhtdZrEzDNVLG8=; b=MFF/9iBwe6mkb0DdXkt+PbIgzzM97KlYRFnL2i0oNS7lMhZOij3g8Dd9Mxe4Ri0Y4a 5B1o1qJ5XAX22yjJFzHvYTl+LVIVGVrETyxEfmFDDO8Tg9C9MVkjMO2mqIwVuIhmlxrk XfrnumM2VURnufCqKjXp1pNGs1CKHaHL1X0Hhu6KwdeApReB8xuEIvuH7qPf0nlCJL1q 03ruVcjSR2GjF+cc5iWun+RuN3tbYvCt9IyNII27+TnUaJJ9gnE5ueRoUpf1H1nUl9H5 taSF5+b34LPZLgqkYdpY9U2sOe/vrLnINvKJ81yrWHycrOMkBaP8aYBHE3A+R4nTvsTP ugfg== X-Gm-Message-State: AOJu0Ywrsb+PQlmYsGgwbN11aZ/2Ri/DGGBX2LZYHTrU0dk02rJfSfjc L/KqiWYqS6w2YS8Uzm8m++obXspVRQIX/h2VuDwRTA== X-Received: by 2002:a05:600c:3ca1:b0:3fe:cd3a:ef92 with SMTP id bg33-20020a05600c3ca100b003fecd3aef92mr2871wmb.6.1692306811600; Thu, 17 Aug 2023 14:13:31 -0700 (PDT) MIME-Version: 1.0 References: <20230812210053.2325091-1-zokeefe@google.com> In-Reply-To: From: "Zach O'Keefe" Date: Thu, 17 Aug 2023 14:12:54 -0700 Message-ID: Subject: Re: [EXTERNAL] [PATCH] mm/thp: fix "mm: thp: kill __transhuge_page_enabled()" To: Matthew Wilcox Cc: Saurabh Singh Sengar , Dan Williams , "linux-mm@kvack.org" , Yang Shi , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 17, 2023 at 12:01=E2=80=AFPM Matthew Wilcox wrote: > > On Thu, Aug 17, 2023 at 11:13:36AM -0700, Zach O'Keefe wrote: > > > > IIUC then, there is a bug in smaps THPeligible code when > > > > CONFIG_READ_ONLY_THP_FOR_FS is not set. Not obvious, but apparently > > > > this config is (according to it's Kconfig desc) khugepaged-only, so= it > > > > should be fine for it to be disabled, yet allow > > > > do_sync_mmap_readahead() to install a pmd for file-backed memory. > > > > hugepage_vma_check() will need to be patched to fix this. > > > > > > I guess so ... > > > > The easiest and most satisfying way to handle this -- and I think we > > talked about this before -- is relaxing that complicated > > file_thp_enabled() check when the file's mapping supports large > > folios. I think that makes sense to me, though I don't know all the > > details fs-side. Will we need any hook to give fs the chance to update > > any internal state on collapse? > > If the filesystem has per-folio metadata, we need to give the filesystem > the chance to set that up. I've vaguaely been wondering about using the > ->migrate_folio callback for it. At the moment, I think it just refuses > to work if the folio isn't order-0. Ok, no free lunch here then. I'll give myself a reminder to come back here then and dig a little deeper. Thanks Matthew > > > > But I have a larger question for you: should we care about > > > > /sys/kernel/mm/transparent_hugepage/enabled for file-fault? We > > > > currently don't. Seems weird that we can transparently get a hugepa= ge > > > > when THP=3D"never". Also, if THP=3D"always", we might as well skip = the > > > > VM_HUGEPAGE check, and try the final pmd install (and save khugepag= ed > > > > the trouble of attempting it later). > > > > > > I deliberately ignored the humungous complexity of the THP options. > > > They're overgrown and make my brain hurt. [..] > > > > Same > > > > > [..] Instead, large folios are > > > adaptive; they observe the behaviour of the user program and choose b= ased > > > on history what to do. This is far superior to having a sysadmin tel= l > > > us what to do! > > > > I had written a bunch on this, but I arrived to the conclusion that > > (a) pmd-mapping here is ~ a free win, and (b) I'm not the best person > > to argue for these knobs, given MADV_COLLAPSE ignores them entirely :P > > > > ..But (sorry) what about MMF_DISABLE_THP? > > Yeah, we ignore that too. My rationale is -- as you said -- using the > PMDs is actually free, and it's really none of the app's business how > the page cache chooses to cache things. What should be done to be consistent with the collapse side here, for file/shmem if at all? Answering the question, "can this memory be backed by THPs" is becoming really complex, and that THPelligble smaps field is becoming increasingly more difficult to use.