From patchwork Tue Sep 3 23:22:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Yznaga X-Patchwork-Id: 13789496 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 889C2CD37B5 for ; Tue, 3 Sep 2024 23:23:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 119498D01F0; Tue, 3 Sep 2024 19:23:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C97E8D01E4; Tue, 3 Sep 2024 19:23:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E83FE8D01F0; Tue, 3 Sep 2024 19:23:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C866F8D01E4 for ; Tue, 3 Sep 2024 19:23:37 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7C3101C441F for ; Tue, 3 Sep 2024 23:23:37 +0000 (UTC) X-FDA: 82525006074.17.934054B Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf21.hostedemail.com (Postfix) with ESMTP id 8D9CD1C0007 for ; Tue, 3 Sep 2024 23:23:35 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=O5D6NE1h; spf=pass (imf21.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=anthony.yznaga@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725405720; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+NwCsMY5ut7geDTvEdbHpELHUG2vwXaB0hfwIYvPX5k=; b=VdztY0hdWfqrVIKuqi+8B92UHvRiiCC04NaSi4CGIy1PnMIQqBTsHIV9F4OiHx1MXTizE5 7MOdFYpVZGtoL/WAqD+StTeLWxzNrvk3U0YMXEIiFl5rqqhdUU+F4+vnTnLarKf9yvwZ+d 8THjKFeDVTN0/s5LK00xvvcCfC11s+I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725405720; a=rsa-sha256; cv=none; b=p54IiLEFw1NZllz7d5qxI2oYKPk4IHB09gab2j6GRqc2G+pvmOVMMpW+OmFsE4crzHsYOM aMor7n70Rw5k0ngpfc1RNFtnbTrYUPXXdDHSL46b3NhgO0SkG1fHwzbY2VXuPneKguEbvs /BC16T+ARa3Rvpae0fmVDPyXOjm33aM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=O5D6NE1h; spf=pass (imf21.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=anthony.yznaga@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 483LBdVa002918; Tue, 3 Sep 2024 23:23:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=+ NwCsMY5ut7geDTvEdbHpELHUG2vwXaB0hfwIYvPX5k=; b=O5D6NE1hAI1ca/5Ka oNy0zYRbgBGl2kvJhbEFSE2t+s+VAqS5Itxo/2SwVNf8M9ByxtnzA+NG7rJnm7hu dKHsrAsHwjW5c2ZzAcCr44IVNtX6avwvIpqrGhuhAjkxpoE5yljmk5LKlsUApeAX wC5xQOYUl/diPl48xpZELiIr1vlTBrX86VEVJUCzmbh93L8PMabujNaI6SjRUzHe ga2a6MNm0f21zOLZ/IQvffXdguxhARqZAr2N0T8rkqMypo3qQgYzEPHVjYo4eS8I Ae+/0tBxEmbRXW7mc8M2Ycu3SODKyrTFuyTlmxcTUp/GgnTkzwG//pRma2IqyHFf Hbsxg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41dvu7a3u3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 23:23:21 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 483L0q9W001754; Tue, 3 Sep 2024 23:23:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41bsmfmn96-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 23:23:20 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 483NMkfA040456; Tue, 3 Sep 2024 23:23:19 GMT Received: from localhost.us.oracle.com (dhcp-10-159-133-114.vpn.oracle.com [10.159.133.114]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 41bsmfmmwr-3; Tue, 03 Sep 2024 23:23:19 +0000 From: Anthony Yznaga To: akpm@linux-foundation.org, willy@infradead.org, markhemm@googlemail.com, viro@zeniv.linux.org.uk, david@redhat.com, khalid@kernel.org Cc: anthony.yznaga@oracle.com, andreyknvl@gmail.com, dave.hansen@intel.com, luto@kernel.org, brauner@kernel.org, arnd@arndb.de, ebiederm@xmission.com, catalin.marinas@arm.com, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhiramat@kernel.org, rostedt@goodmis.org, vasily.averin@linux.dev, xhao@linux.alibaba.com, pcc@google.com, neilb@suse.de, maz@kernel.org Subject: [RFC PATCH v3 02/10] mm/mshare: pre-populate msharefs with information file Date: Tue, 3 Sep 2024 16:22:33 -0700 Message-ID: <20240903232241.43995-3-anthony.yznaga@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240903232241.43995-1-anthony.yznaga@oracle.com> References: <20240903232241.43995-1-anthony.yznaga@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-03_11,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2409030187 X-Proofpoint-ORIG-GUID: GfvRugAIhgIXGKZZXnPMCuCQwggq_Rr6 X-Proofpoint-GUID: GfvRugAIhgIXGKZZXnPMCuCQwggq_Rr6 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8D9CD1C0007 X-Stat-Signature: 68zqhzjmmqx46c6jn9x5ejrcr5fehz36 X-HE-Tag: 1725405815-106604 X-HE-Meta: U2Fsd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5K4UQr3wSiEuh+lPCiTzWhO3LIVS16WDXUGsD/DyXZbUUhFv96fM7csBp5FuBDUEWXZ5M6rg6HKuTs7araSgHgX9yT1ox/a7axV1i9E3179hyDaOURFqobjPKI8yeckqTA+wdVgzMxyUu8eVaVl0AQSLxFrDzeAbSl0LZREoxiKWEE= 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: From: Khalid Aziz Users of mshare feature to share page tables need to know the size and alignment requirement for shared regions. Pre-populate msharefs with a file, mshare_info, that provides this information. Signed-off-by: Khalid Aziz Signed-off-by: Anthony Yznaga --- mm/mshare.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/mm/mshare.c b/mm/mshare.c index d5d8e2530e5a..6562000545e1 100644 --- a/mm/mshare.c +++ b/mm/mshare.c @@ -17,19 +17,73 @@ #include #include +struct msharefs_info { + struct dentry *info_dentry; +}; + static const struct file_operations msharefs_file_operations = { .open = simple_open, .llseek = no_llseek, }; +static ssize_t +mshare_info_read(struct file *file, char __user *buf, size_t nbytes, + loff_t *ppos) +{ + char s[80]; + + sprintf(s, "%ld\n", PGDIR_SIZE); + return simple_read_from_buffer(buf, nbytes, ppos, s, strlen(s)); +} + +static const struct file_operations mshare_info_ops = { + .read = mshare_info_read, + .llseek = noop_llseek, +}; + static const struct super_operations mshare_s_ops = { .statfs = simple_statfs, }; +static int +msharefs_create_mshare_info(struct super_block *sb) +{ + struct msharefs_info *info = sb->s_fs_info; + struct dentry *root = sb->s_root; + struct dentry *dentry; + struct inode *inode; + int ret; + + ret = -ENOMEM; + inode = new_inode(sb); + if (!inode) + goto out; + + inode->i_ino = 2; + simple_inode_init_ts(inode); + inode_init_owner(&nop_mnt_idmap, inode, NULL, S_IFREG | 0444); + inode->i_fop = &mshare_info_ops; + + dentry = d_alloc_name(root, "mshare_info"); + if (!dentry) + goto out; + + info->info_dentry = dentry; + d_add(dentry, inode); + + return 0; +out: + iput(inode); + + return ret; +} + static int msharefs_fill_super(struct super_block *sb, struct fs_context *fc) { + struct msharefs_info *info; struct inode *inode; + int ret; sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = PAGE_SHIFT; @@ -37,6 +91,12 @@ msharefs_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_op = &mshare_s_ops; sb->s_time_gran = 1; + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + sb->s_fs_info = info; + inode = new_inode(sb); if (!inode) return -ENOMEM; @@ -52,7 +112,9 @@ msharefs_fill_super(struct super_block *sb, struct fs_context *fc) if (!sb->s_root) return -ENOMEM; - return 0; + ret = msharefs_create_mshare_info(sb); + + return ret; } static int @@ -72,10 +134,19 @@ mshare_init_fs_context(struct fs_context *fc) return 0; } +static void +msharefs_kill_super(struct super_block *sb) +{ + struct msharefs_info *info = sb->s_fs_info; + + kfree(info); + kill_litter_super(sb); +} + static struct file_system_type mshare_fs = { .name = "msharefs", .init_fs_context = mshare_init_fs_context, - .kill_sb = kill_litter_super, + .kill_sb = msharefs_kill_super, }; static int __init