From patchwork Fri Aug 18 21:15:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach O'Keefe X-Patchwork-Id: 13358322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0255FEE4999 for ; Fri, 18 Aug 2023 21:15:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F67E940071; Fri, 18 Aug 2023 17:15:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A73F940012; Fri, 18 Aug 2023 17:15:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24769940071; Fri, 18 Aug 2023 17:15:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0ED0B940012 for ; Fri, 18 Aug 2023 17:15:44 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C4967140831 for ; Fri, 18 Aug 2023 21:15:43 +0000 (UTC) X-FDA: 81138482166.15.2910C13 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf08.hostedemail.com (Postfix) with ESMTP id 02CDE16002B for ; Fri, 18 Aug 2023 21:15:41 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=JDIkLrwO; spf=pass (imf08.hostedemail.com: domain of 3fd_fZAcKCOgjYUOOPOQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--zokeefe.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3fd_fZAcKCOgjYUOOPOQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692393342; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Jem4cROi9qphCIk8SA3V6xQmrxAyRIHLARImADDaneY=; b=HXgXgiFYVCAKL0X556+tscwGjN5djGJ/HJyHWXo+QzNFuH5rIh19sqkDQ1lDYfnD+aBDwG 3Wyr7TiDCK3ipbyS+MCrSBbQUBQmL1OmRCdkrHFMJYnRL9BTWEJUKOMkjk7sfpf+oHmbhW n3rT5vlswCa3oo7qAdXKpqMp4B75Yxc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692393342; a=rsa-sha256; cv=none; b=x5P+SuIA9+waND/4tXJQjX/WqokcVwj/MiVCBBeTFTyVkPonKvo444qdc9vgo5nV5GqX20 vPdrdtopDXRMJ6RUhW6IdSYFWacgSLmhMebBib6VS4rQid8LAtRrzju2lOHhpA/iUaLUm3 xYZyNhal8z0Wiq7h9TPo/Wb/t/W5/zk= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=JDIkLrwO; spf=pass (imf08.hostedemail.com: domain of 3fd_fZAcKCOgjYUOOPOQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--zokeefe.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3fd_fZAcKCOgjYUOOPOQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-d62a7776f69so1551518276.3 for ; Fri, 18 Aug 2023 14:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692393341; x=1692998141; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Jem4cROi9qphCIk8SA3V6xQmrxAyRIHLARImADDaneY=; b=JDIkLrwOMLZTuos/xJL8m9DbQKbG5PZAeRI5YmFAkVnFqfqKDRmkNWTjR2ydHBchos ZwTUsGsPPeler78kiUryIeo+RZX0H/nGn4Wh1lTy4LUyNCGaMaZj2YkkUicNShAMrqN+ Mle1SCWpxQdxQYeTzmN22S1/kcb2tzw1FzKE+hwzaHLpJGsGK5HJMQOt8sXNOa3NdZr/ 9gJ5cK8ifGCDq0MEuvKm/zb4JSPPMTfG4vX4uWTt7JpEmgL2moGX7M+hCugQqZ70m/nn B5bDYj8LHyHcZw0pr5uB7dkV3BuQybQmFnu79C1Kof2qjh71mdNoj20PPf81kF/WAFRU m3aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692393341; x=1692998141; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Jem4cROi9qphCIk8SA3V6xQmrxAyRIHLARImADDaneY=; b=gZEMOaMMZ9U40zWzF0OcD8ltGayW1hmZoOlwCSJ/jHMBJwoa92A1dL0c7dCHWNjgjy bh0AtDtL3JRfxRoAzxzFm+Kajuo6Iv8+oVAjZKLg8Fs2uLUQefO2jMvKtZSE3y9LURUz U9uwGZvMXImERcgXI4k4XimhBWOs6xxecPFMhwbrf0ZhXoYTQp61/+Yr6whjhryzBKV9 oqPM2yz3M0vHkVQGpwoYWnBgrNQ95Dgw8bdWfj2OGOvdcr+X+GGhLWpIxDWTyhfLW7b8 edmZyY0LoSdXVuQss63QVHf/0HCtMzar4vUFkmtClu+IisnAAvGnsj+bN+K1tCvFaPXs YQwQ== X-Gm-Message-State: AOJu0YwVo6af9waEcWH9AcYaoly+LOtEZ1axJGrQdlPBT50vVe367yuR cfpWgT6hQ+OifRzrTBHdIcxk+45N24MzIbtzoE++CU3cofhWTEg09eZwmDtsXNpS8CymXHraqK5 isXv/L0YTepja3B498orzhVOuHaLLzkUv/HSzHnjVYKoVLez7qAq1QFTAqho= X-Google-Smtp-Source: AGHT+IGRa2stsy8QZJfi6RdwZ3CiSQz8GGgelTAbogELSmuy2F7S/d9Slg4Cg25/asaaViD4egyWmEAMAlQi X-Received: from zokeefe3.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1b6]) (user=zokeefe job=sendgmr) by 2002:a05:6902:290:b0:d48:c04:f256 with SMTP id v16-20020a056902029000b00d480c04f256mr3251ybh.11.1692393341040; Fri, 18 Aug 2023 14:15:41 -0700 (PDT) Date: Fri, 18 Aug 2023 14:15:33 -0700 In-Reply-To: <20230818211533.2523697-1-zokeefe@google.com> Mime-Version: 1.0 References: <20230818211533.2523697-1-zokeefe@google.com> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog Message-ID: <20230818211533.2523697-2-zokeefe@google.com> Subject: [PATCH v2 2/2] smaps: set THPeligible if file mapping supports large folios From: "Zach O'Keefe" To: linux-mm@kvack.org, Yang Shi Cc: linux-kernel@vger.kernel.org, "Zach O'Keefe" , Matthew Wilcox X-Rspamd-Queue-Id: 02CDE16002B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: kx1fqke76m86xdjmcd3kyzwtnnjdybec X-HE-Tag: 1692393341-238741 X-HE-Meta: U2FsdGVkX18q6ZRAsbY9Lgv6OFTXFo/4+mOo2rdKPrVcXdUiEsfnpr3MKHouMK/iZB6LfzGzPL5DDlSoR7AZZC++3eKCGC4NoFCjwvcyxaS+4g5k1KnnEi8SM+TT4Q2k16zUgKLO2GhTJdA+gleEpZJJco/I61H3fTd1eAVwOHyMDzf0RMpVHIpO7xwGlpwXVLdEPtjermIaL+0SYeq4zfj4JTpYKKH1ZKwc8JXo7z5HxywMuke8wd1Tw5GjIkyvM9CHKUyC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eQL5oaLRR588SS16+m2kRbx5pn9VKqJd4ycFZXmTBU1WHq8f+1zDuXMOx48M5ZxNp/eWf87mmBQ0CqCiPehNndXFC4/4ziU6J/n2EtxWdyPCdkbmqi+3cj/OCsg0KyZWMpC2IGptoFp24njPxO+sPwaihQ5WNDzbFFYFOltOYJjD/X0KPUtAAFVCWHOoRhbS+4uqJqAClI+uinKGnCZ5ZplDhrU2nPaBZE/gHEuKDIBq9KgzArsyVnmk0oI/yIC77U7dNyOJW9selclEmrCN+OpnkbuKMSnWtt+CePG2mA//qL+RQ19qd2wT7LF8NU9ucHApUmRD6JJB6PJ33kW8EPjHTs= 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: File-backed memory can be backed by THPs either through collapse, when CONFIG_READ_ONLY_THP_FOR_FS is enabled, or through fault, when the filesystem supports large folio mappings. Currently, smaps only knows about the former, so teach it about the latter. Signed-off-by: Zach O'Keefe Cc: Matthew Wilcox --- mm/huge_memory.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index cd379b2c077b..d8d6e83820f3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -136,7 +136,16 @@ bool hugepage_vma_check(struct vm_area_struct *vma, unsigned long vm_flags, */ !!vma->vm_ops->huge_fault : /* Only regular file is valid in collapse path */ - file_thp_enabled(vma); + file_thp_enabled(vma) || + /* + * THPeligible bit of smaps should surface the + * possibility of THP through fault if the filesystem + * supports it. We don't check this in fault path, + * because we want to fallback to the actual ->fault() + * handler to make the decision. + */ + (smaps && vma->vm_file && + mapping_large_folio_support(vma->vm_file->f_mapping)); if (vma_is_temporary_stack(vma)) return false;