From patchwork Mon Feb 6 14:21:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charan Teja Kalla X-Patchwork-Id: 13130019 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 F1226C636D6 for ; Mon, 6 Feb 2023 14:22:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 909D46B0073; Mon, 6 Feb 2023 09:22:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7AF7F6B007B; Mon, 6 Feb 2023 09:22:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D6DF6B007D; Mon, 6 Feb 2023 09:22:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 49E906B0073 for ; Mon, 6 Feb 2023 09:22:26 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D8286A01CD for ; Mon, 6 Feb 2023 14:22:25 +0000 (UTC) X-FDA: 80437082250.24.8A3B7E3 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf30.hostedemail.com (Postfix) with ESMTP id 998CB8001C for ; Mon, 6 Feb 2023 14:22:22 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=E0+YTtow; spf=pass (imf30.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675693342; 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=z16qL464jjHlCAViTyAzYRDp++e/SOG/2UVptENsEGo=; b=h++jtOjVw7+4HmjSTmYAjA5qH+wtIkEYKdudDZA2CtaPozdiE2O6JlMmCa8RmT9iHOgNB2 VwPrGaIO7jngeNnOZzMC7D87aBcQ04d2jWFLmUoBacDv7jbyxHgHVY4E5+wfqfnbQL+PU7 R8SKFeeT5m2CzuDG3axl/JERTGYDkTc= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=E0+YTtow; spf=pass (imf30.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675693342; a=rsa-sha256; cv=none; b=MDQ+lMjNab6oXX6mdRSbRsYSAK3JcSAh7P6UroU+qk3x/ByQVPGK8DOcu3VsSRHV37g7g5 g11NKe2mc+tAuezb7b3C7oUf0WOw/052jKAoNBajN08w36vuB+M+hxYInWpWx45KS7d4Vc invjJXYVgMD2p1ULW+1wnj80BbsoeoQ= Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 316CBGsb012728; Mon, 6 Feb 2023 14:22:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=z16qL464jjHlCAViTyAzYRDp++e/SOG/2UVptENsEGo=; b=E0+YTtowsmFGO5B3QrtTDOpLH+ZuSmQdDMhwEcPZFQad0tTzCP+nbF4MNgVmiFeEnD7M ijpaRh/ZgHRG34zD5ngFk+1BpocHidpSZFF815pbCALDrge35Lrpt43At+GMsWMDz9n9 qyvMrGl1IBvikbe6kay3EZhIuHR4ZF8qlRcQ+HnoQZH9iQk22IMrLCmda+/eWka9HCbF OI3Jyi9mX42wMzHZTcTbe256vSqhY5eybcsw6T0zo0z2KiyIFy5iu+sO7ZoxNnWYE7wg JD3hoZrfW94+Vv4pFT6ctz0B/h3Iwv4iernFFqdg7bWy5pwPuRA8EmIvyDZR6tDhc+h7 EA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nhg4rkp5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Feb 2023 14:22:09 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 316EM9Te003936 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 6 Feb 2023 14:22:09 GMT Received: from hu-charante-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:22:04 -0800 From: Charan Teja Kalla To: , , , , , , , , , CC: , , Charan Teja Kalla Subject: [PATCH V6 0/2] mm: shmem: support POSIX_FADV_[WILL|DONT]NEED for shmem files Date: Mon, 6 Feb 2023 19:51:31 +0530 Message-ID: X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 9s_6ra1D45UOIxe7M8KVQxPNMCSfwB9y X-Proofpoint-GUID: 9s_6ra1D45UOIxe7M8KVQxPNMCSfwB9y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-06_07,2023-02-06_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 impostorscore=0 phishscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=432 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302060123 X-Rspamd-Queue-Id: 998CB8001C X-Stat-Signature: 1huzspje5oirxwwfr7sfrkt3ome1hzwc X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1675693342-31702 X-HE-Meta: U2FsdGVkX18rzg4NobD1sO1Ndt0RmA9dG2oVnbdzHafRFxT3ZONsjBKdRoI85728eb0D5+Rc+i2N6V9MczLVyWB8+dghpM2ZwMav5eZfhOD7awUsg2ea6HeFAWXH3wHy7U4eBi/nHFprujJw8O6ftwi11nmzxiCiEzcnS1BDjvtacZWBAGiT/GV9iDafeQtu2jWkUmriDcBi3JaUwgBNKjNr9mypVEsMuTl13mT/CG1vOn66V1c5Ins2iNbHZsQjkQ/GPcCM7rCid8U+qApD8c53Iw3TY4ANTKm/XJZ0DVD9XmQ0q0Gsdr1Kt9+ajsPbMiVu7+KsCsG5gk8V+K0E3nxESKQGJJ5lU5criYsDmrsESWxU+bt8WSK5P+zHHjv6twNdRnVPy7GbmSCZ5tIG5Krd+Bd6iUKXgSi4+W7IJi53j8GNO6tI+8oQfr4WiwE4kUlKn3UnynVCJWxYHTpO3dDX9Hx+TRFOz67McooT7f4O93LhW0c2/+lPGXCkof//zoQjjrCpjRIeVhZSXVYcadIAk7Vgo3uM7OvFbRLYx+Lh/gPCvDYf/Rp6xnMp7DMBBkeb4f89/L6S4mYB2xjWJglx2iKTxEI67FiKNmzgvVO9FsLT700kNrebixNDGcSi3XN3OZrv+CjYSoKILU/n5XxY/vcHflFaBop+alLVMHfRaJqKRwxvXEbmfuEBERdlGalz02dOiZH4fhWBH5w6tSjWCtfE6XafZnE8lvG11L9GXSOQAad7sTxr5Cf9CjK2IUt61/YqAKnvTinCi69cbl7rRmk7iSQrfosK06wTuSVD3ifEpYtWv1t40H9ojwLif7sllF+C2aoqqqajJeThYB5QK4kk9/PKQrkTz50AM90q4TYXuZgg5qXw+TZJlt9hgcsHgKijimnj4SRMXbfabuExvVcb7qyZFWf4QdxCcEJM/tCB2wuikII2T12Z3xPsotU3B8P9gONEWrvM7d3 QcrRzh// +ECavG7md9wHZ3kSTm7AWYzEtEba+y1R4So8+zi3vAJPjJ9+kfMwXeG4hSDDPxSgxUbsqNqfiPDC1SJHRwwc1dw7Y91uVcx4NUg9b3SaBK8/a7Siki6fgQS0tobS8trl7k9hqoJxUzscpNJcNJSjrqO31iEoTq4oZsoqR26+IZGNAiTIro8bwBM/9zuOip4VPm59tTV59/1VtGh2zBbzSsX9YaKd18ZzVBtfaW0fu5uiBhKdnzsz3WTkUptgrjeXAfJv4QZ5zUsUwoX4tW9VtY7sLj2T+akm+82YNuw6bY0wOxhZcWrKKWiS1kQgx7OLKFatlQciPZAzyu1Skj6/al+4K2NrSKofXX09xBGTPybyrVMXHoAR1wHJKlmtHTsmMqgZzzSbTBgZjms0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.017370, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This patch aims to implement POSIX_FADV_WILLNEED and POSIX_FADV_DONTNEED advices to shmem files which can be helpful for the drivers who may want to manage the pages of shmem files on their own, like, that are created through shmem_file_setup[_with_mnt](). Changes in V6: -- Replaced the pages with folio's for shmem changes. Changes in V5: -- Moved the 'endbyte' calculations to a header function for use by shmem_fadvise(). -- Addressed comments from suren. -- No changes in resend. Retested on the latest tip. -- https://lore.kernel.org/all/cover.1648706231.git.quic_charante@quicinc.com/ Changes in V4: -- Changed the code to use reclaim_pages() to writeout the shmem pages to swap and then reclaim. -- Addressed comments from Mark Hemment and Matthew. -- fadvise() on shmem file may even unmap a page. -- https://patchwork.kernel.org/project/linux-mm/patch/1644572051-24091-1-git-send-email-quic_charante@quicinc.com/ Changes in V3: -- Considered THP pages while doing FADVISE_[DONT|WILL]NEED, identified by Matthew. -- xarray used properly, as identified by Matthew. -- Excluded mapped pages as it requires unmapping and the man pages of fadvise don't talk about them. -- RESEND: Fixed the compilation issue when CONFIG_TMPFS is not defined. -- https://patchwork.kernel.org/project/linux-mm/patch/1641488717-13865-1-git-send-email-quic_charante@quicinc.com/ Changes in V2: -- Rearranged the code to not to sleep with rcu_lock while using xas_() functionality. -- Addressed the comments from Suren. -- https://patchwork.kernel.org/project/linux-mm/patch/1638442253-1591-1-git-send-email-quic_charante@quicinc.com/ changes in V1: -- Created the interface for fadvise(2) to work on shmem files. -- https://patchwork.kernel.org/project/linux-mm/patch/1633701982-22302-1-git-send-email-charante@codeaurora.org/ Charan Teja Kalla (2): mm: fadvise: move 'endbyte' calculations to helper function mm: shmem: implement POSIX_FADV_[WILL|DONT]NEED for shmem mm/fadvise.c | 11 +----- mm/internal.h | 21 +++++++++++ mm/shmem.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 10 deletions(-)