From patchwork Wed Dec 20 05:41:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fangrui Song X-Patchwork-Id: 13499563 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 158BBC3DA6E for ; Wed, 20 Dec 2023 05:41:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC1DD6B0075; Wed, 20 Dec 2023 00:41:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A71066B0078; Wed, 20 Dec 2023 00:41:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95FB06B007B; Wed, 20 Dec 2023 00:41:29 -0500 (EST) 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 837D16B0075 for ; Wed, 20 Dec 2023 00:41:29 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 586EDA1FFB for ; Wed, 20 Dec 2023 05:41:29 +0000 (UTC) X-FDA: 81586099098.14.899BD4A Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf10.hostedemail.com (Postfix) with ESMTP id C2CBAC0002 for ; Wed, 20 Dec 2023 05:41:27 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=OSng2AWQ; spf=pass (imf10.hostedemail.com: domain of 3hn6CZQcKCL8rfxpwf3lttlqj.htrqnsz2-rrp0fhp.twl@flex--maskray.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3hn6CZQcKCL8rfxpwf3lttlqj.htrqnsz2-rrp0fhp.twl@flex--maskray.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703050887; a=rsa-sha256; cv=none; b=eY9vgEeROmgl9TOWI/AhaYRKpylrubyu6VWxWYdxXtypP9tzZsgLtsfZxJJ+19CW7sdVF8 gLdkjbBzI5kRS0iIyaQkzLGNN+mNEcnRrHM2TpQcx1f/AaABKGdvmKoJOSlDtqOit0AN/g RWF1lDaAyi0Ja2/P//GXJ4D4lE/H0GU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=OSng2AWQ; spf=pass (imf10.hostedemail.com: domain of 3hn6CZQcKCL8rfxpwf3lttlqj.htrqnsz2-rrp0fhp.twl@flex--maskray.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3hn6CZQcKCL8rfxpwf3lttlqj.htrqnsz2-rrp0fhp.twl@flex--maskray.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=1703050887; 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: references:dkim-signature; bh=CnjYMOrzwkCbD0FGgIKrRfe2ITqCmTOHmPVslRt7U1U=; b=JtS8lw8UrH8sVSWNLNJctOdCnV6xj6ts//XtAGckhuP7i6d3M3Pr8iPzp+r6fvlJ54jY5A MMAwDyyX5IsKzJpxp8qgo1FWxECPruDCkAJWDUVADHE4CEjAaFXq4cin/FcnItD3f7FOsz ZKzY3ThUQ4CNsiYUfRHnMyCV/F1AQE0= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-5e56d85fa91so51595787b3.2 for ; Tue, 19 Dec 2023 21:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703050887; x=1703655687; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=CnjYMOrzwkCbD0FGgIKrRfe2ITqCmTOHmPVslRt7U1U=; b=OSng2AWQIZdHZZDBP0/qc5C18hTmvA2GlTWkl9jR4EKznnayPdVksjbv/4TuDwj9+5 PEF6/5Dmqr8n31Q9hzBlJiIIW+6+C101xA0TD5s/7yi9wijLsEfhCzOjM/0zEQT5XpLy IFj8esMUBWGtcg9FuyxEgYUaBS8zwblltzATiks4xvkOZ/+T+GChLdSNhSy0EqzkhyxX I9PPCuJmXJxKcn2pzSAfVdZ4BWUSOky8KkB8aie9dNqbNEX37EnKbKdt0iDqcl2SLdbG uaEPmC7Ip6tkg8MUdIIN5DyoqLX7lIw4u6/JkYWCLz/o/U2XVbbwYiWTe5qSJRAj4q1c cWgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703050887; x=1703655687; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=CnjYMOrzwkCbD0FGgIKrRfe2ITqCmTOHmPVslRt7U1U=; b=xFYgeVFa9gJd2azRdN2UdmlQAsKsnmFeF92xGVjjqY3Wdg3asWr+2+OA/EV1B1aAc1 1CGBLhqOVGGqUhid8IdxZdzqf4Fzat9psk29ItNVEIzbj64FJRU15ZpR2zQL0r7tyNGl YY0OkHRvRIKRD1q0S5QKfn4gWdds1QmbNK8f9zwiIyaNKTeElQLNghpDfRQP7wr2gKFD t2a43YzxnVd9toa39d6MNO3/wAipct3+QZSADZ3V618LzFTg5mhsCz3QaOAeW4Z95v0P 8XYYFY2gLytw3cImoPbL8LZfoRrKUCmDAVQc+jKyEooYgmePNiCQQNfAqEQu+BzC96f7 l6DA== X-Gm-Message-State: AOJu0Yz374iK2xydqyaBuv7DU4suGZTqRO4rQ36hD2hKCN/msxjXsNmF 4VhNvp6UALwnXRqj10+ulpOeioVIhQG6 X-Google-Smtp-Source: AGHT+IGsueOMSkzfT0nYUCSgWkoGnWUStrlsrh8rK9jGlSMZG6/vJuqKWRaSppbB0sEpgT9yBQPAGcTvvfka X-Received: from maskray.svl.corp.google.com ([2620:15c:2d3:205:405:b62:49a3:2869]) (user=maskray job=sendgmr) by 2002:a05:690c:841:b0:5e8:3e57:68e3 with SMTP id bz1-20020a05690c084100b005e83e5768e3mr537282ywb.10.1703050886884; Tue, 19 Dec 2023 21:41:26 -0800 (PST) Date: Tue, 19 Dec 2023 21:41:23 -0800 Mime-Version: 1.0 Message-ID: <20231220054123.1266001-1-maskray@google.com> Subject: [PATCH] mm: remove VM_EXEC requirement for THP eligibility From: Fangrui Song To: Andrew Morton , linux-mm@kvack.org Cc: Song Liu , Yang Shi , Miaohe Lin , linux-kernel@vger.kernel.org, Fangrui Song X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C2CBAC0002 X-Stat-Signature: wq959ahm1akez5ad1d6gpy3nwykh11zc X-Rspam-User: X-HE-Tag: 1703050887-704410 X-HE-Meta: U2FsdGVkX1/dXNfXeUGQy4owuPt1dt9Cawc3GGSVd9X3NkGO76711sGHbQCrZWIRqnt7chNt+dELSdgUl0IOafwbNS6J/4IidQF6jQ6/RSAiE3Ahlhm/WVKT9QadzDhPjyNLnIu7raIxKxSE3p8JIAiUn98I3Ytl2uSSr27pfIxkCP9a7zx+GWHAMqRrBp62TJ1ZpljKB9G+4/gT+dfQPvE8zWFVt/uV4fPlf0ez7UL/1s+XZurEITt0VMUCI/CO2oAJvB7nrrOJ1Tc3Z/itXydHQIkw14mPqWUFlGyt5xW5LQnXoleQBHDbHosxotiNr7tAemZu6cRstvn8BHng1tjQQepUKFOIn7n2sLd26+3fkBDIsih/1vB9QaBuejijGwlPo9VBOtRrGUM+da2eBAek63IZ+ZP0B/MyJMUBYbgJkXCJcXVhKQlWcTmiaR0zATVx2u+aZ5ztCjQ0Py+921vYRk4/z4g0cg5/1Uoo2yzrLNyr5oc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X8e8MCG7LYEChlqN0gRam6GsPmQRCINnX/X3VakOvowYxe13zoiwYf8rRfyomxk7oJu4eoDxQ6YFpIG48sW/ye1V9uE 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: List-Subscribe: List-Unsubscribe: Commit e6be37b2e7bd ("mm/huge_memory.c: add missing read-only THP checking in transparent_hugepage_enabled()") introduced the VM_EXEC requirement, which is not strictly needed. lld's default --rosegment option and GNU ld's -z separate-code option (default on Linux/x86 since binutils 2.31) create a read-only PT_LOAD segment without the PF_X flag, which should be eligible for THP. Certain architectures support medium and large code models, where .lrodata may be placed in a separate read-only PT_LOAD segment, which should be eligible for THP as well. Signed-off-by: Fangrui Song --- include/linux/huge_mm.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index fa0350b0812a..4c9e67e9000f 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -126,7 +126,6 @@ static inline bool file_thp_enabled(struct vm_area_struct *vma) inode = vma->vm_file->f_inode; return (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS)) && - (vma->vm_flags & VM_EXEC) && !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode); }