From patchwork Tue Feb 14 12:51:48 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: 13140008 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 E698CC05027 for ; Tue, 14 Feb 2023 12:53:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 85FEF6B0075; Tue, 14 Feb 2023 07:53:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E8B06B0078; Tue, 14 Feb 2023 07:53:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68AA66B007B; Tue, 14 Feb 2023 07:53:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 566636B0075 for ; Tue, 14 Feb 2023 07:53:31 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2C61B120E90 for ; Tue, 14 Feb 2023 12:53:31 +0000 (UTC) X-FDA: 80465888622.28.48C2989 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf30.hostedemail.com (Postfix) with ESMTP id 21A7480023 for ; Tue, 14 Feb 2023 12:53:28 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=WdyZTjq5; spf=pass (imf30.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.180.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=1676379209; 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=zehFsAhHoBrT3wPJAhlchQvE+e0/uYpQajpllFs2EdA=; b=LLnWiAFJzl4l/kgcm1FvHtq9ILWPs9NH+LHmgoqWOIEv6iSKkqy7RZ2fAVKA1bpxvC5MEe ex4J3FxOnkSFBa0xAyWuGZ7Ga968uKYVyKOrYYJsT0uJYQcR9yoXKSUhBKzUgeI3IH+yaK vIg9b/KQ+lyLbYDk7ose5rxhNFLi8KM= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=WdyZTjq5; spf=pass (imf30.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.180.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=1676379209; a=rsa-sha256; cv=none; b=txQn+MTCMBNR+RuKTWpBGjiqxo1E0zt+bMQ/6ZWFp6g8URJUiLpFlkRjBghNIette85rYE KvIPcaN90bzahQJbe2LlJViAbQV0F9YUf5ShL1zcT/ZaW/ECGy1tQawVdI26I6ASMmDn8w 2byXtDEPF7jPkxcXfjgiX+ffW+l4PiQ= Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31E5d3Xe014886; Tue, 14 Feb 2023 12:52:36 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=zehFsAhHoBrT3wPJAhlchQvE+e0/uYpQajpllFs2EdA=; b=WdyZTjq5+X41keiJcFpWmLAvnivRPZ6TP14Eqh+0nJthSjxLid+TkwkK9SPVxVWEygrE 5FRSdbIcDcef+zF8TFhuLWCqfMpbWmtM6QhbmWAsIENiY/BxiTDvAZdeLkjYN79F61mH OhUY7UEsNTq0Z1uo3meGd+dwMu66QDgCU0DxS1G0m4WnewWZCqCMi90tznizLvdv98e1 jSSpSbZafSAmn+XpYm3AtE/pLJknR0i0zlgqhd7S+04m151nxha4+pf/8GpPoOFJnu2V AEh0TQX9e0c1mZy76+fQZ0YZoFpaeaowcLcgAyLgSH8KHO4tScgBgNDKbV5xsdQMExNA ow== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nqtv0a4fw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Feb 2023 12:52:36 +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 31ECqZ4C009759 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Feb 2023 12:52:35 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; Tue, 14 Feb 2023 04:52:31 -0800 From: Charan Teja Kalla To: , , , , , , , CC: , , Charan Teja Kalla Subject: [PATCH V7 0/2] mm: shmem: support POSIX_FADV_[WILL|DONT]NEED for shmem files Date: Tue, 14 Feb 2023 18:21:48 +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-GUID: Qu7VaSJ_EvicX5Dg2RYpO0-BsGxL423S X-Proofpoint-ORIG-GUID: Qu7VaSJ_EvicX5Dg2RYpO0-BsGxL423S X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-14_07,2023-02-14_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 impostorscore=0 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 mlxlogscore=294 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302140111 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 21A7480023 X-Rspam-User: X-Stat-Signature: bkgin5pujzzdo68byzipctwer7gkdp3b X-HE-Tag: 1676379208-604229 X-HE-Meta: U2FsdGVkX18OGkQAi6STH7TjvY4l2ZMGwKYscXETCtuMZWxsm7I/Ns6+TzxzY0K1WYfFruO3gc3uemUQScfbQHSmFTg4pqx/bAzUkXDAeJ/ps0NS+q4ajzp19/M4tGCXeu5v87lib1jX35V31n/mdzmh7GbXkgx4whzV2QW+VsUoa8lh2H4oCh03pHewDMLFrn1+sQ+DXYkS4a1Fw2wCSLFPzYzffrtnu35fZMcfynqH8mZWV3lL20PqAR+GyTlrdwJu0r6esiR/OU3d44yZiAc4xQ4eBjHg6k/Y5O3qx1JSu+zGSAUDIfZTlm99lhOvL7Vba5hMhaFhTkYuFMhnOJpdfZXl1WWb7SrHACKBl4JhVXSUtdjVmD7wJXLyVEsY9ty+hIcN1viPfEDr3ntaS5wK0mOGobtLSXH0WqwO5uEjOlyBIZ0zg58IbrHY/Z8Y/NxFdjHausz4iunsDZJcrBbNpAdVIZmYKPFn2Rc2j7ApgSATsdmwiOQ+HZun6+GrvAsQWQVootA8spDyESBgLkfAEHnylp4v6bBIcWr3KysZ/eOw6lw030a+rXjEgHXwiR4muQzknFKdc5qI6qma6lSQICrRacm1Tz2qjWHQqKuD7ZtfcVVLFESF7x3WEiG7GKdMpn7NbbtzLJIcg8ukgLdSUE3lHvgPQYXJ148CsyGn0TOcMpdTd3H38Gr3aLiBzWv1XuUP9jCtgEKZ9EmRjwqDc5Lafi2796K2U1JPDK6rDtdl4+tr4St9QHyQzdLzcXq98kKJLH5QSYiBStFl/GzkkxUANlSnoquldCuW/u3VXnoDbbiJFbmfn5YqrHgH3hY9N4VjfRGU89WU+5WVJN0K1xjRj/EE53aIBGBUS+ZPeesPz+aJuF7jYx4NDeqr84RX9LMHamy13M9e4G201lbUD3nJEd7XKQbQrIAMwnV95t6qVPjIueHOtdwRrLRnLssPUbw2q7Ca/nmGwqb ES9WJ/fU yKBHRiBZlW5kPbM6VXMxQjBZJLcGwqGdJnC0mxWTWeucYcPSVP9n6+qcLh6E6AK9F4Mhjtt2hnqCbGgvQILhR0kv+JVDr03YAGT8qLZYE1wD3K+DE7/5oiiFV2dylvSeBMEDUW+jrO1+y3fPkg9va7Fm4n+IwWHW/B2P/YOcsmUPDXdt7ancouh+sEg//OfezBK56mOP0A6EzpDvGcrY5nnN+ft7C5y18sZh6ceSo/UuAr6PZNEd+p0cSYlAicv3tg6mOlAEflogVlMuGr1AYHsoH96a0s42ct0nXNi7NR0eABwaYkIfK+T9sEjhxDV3O6RKHLFrerUAYyOFiHZao9K+D727WrpViKRxpViwXGKiJtufXrD/Om6k5+j3bbv70oc1zJSiDJyDSC/Y0++kD7rbY+g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.146765, 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 V7: -- Use folio based interface, shmem_read_folio(), for FADV_WILLNEED. -- Don't swap the SHM_LOCK'ed pages. Changes in V6: -- Replaced the pages with folio's for shmem changes. -- https://lore.kernel.org/all/cover.1675690847.git.quic_charante@quicinc.com/ 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 | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 10 deletions(-)