From patchwork Fri Jul 29 00:49:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kassey Li quic X-Patchwork-Id: 12931854 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 B5FAEC00140 for ; Fri, 29 Jul 2022 00:49:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A25E96B0071; Thu, 28 Jul 2022 20:49:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D4DA6B0072; Thu, 28 Jul 2022 20:49:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 874DE8E0001; Thu, 28 Jul 2022 20:49:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 79D626B0071 for ; Thu, 28 Jul 2022 20:49:39 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4D7EF1C7017 for ; Fri, 29 Jul 2022 00:49:39 +0000 (UTC) X-FDA: 79738304478.28.C1AC716 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf24.hostedemail.com (Postfix) with ESMTP id B2344180012 for ; Fri, 29 Jul 2022 00:49:38 +0000 (UTC) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26T0Q76E002672; Fri, 29 Jul 2022 00:49:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id; s=qcppdkim1; bh=Ezgnbwj2vZCxnalAwrv1h3iJGqONGw5JDecLQclWyw0=; b=QPFwBQYDeupPAMXTnL51YMVWKTlk2JT4+mBXznTyBcHwjXSKsOFC/va30X7MDC5xiIdc Gs+U4jyi08L3FyduHJ6Be+TUSNjdq6/fbdMfBXcw4xKI/KYRsrcKWz5iKY2N47zYbeYV 0UxlSfBVSdTIMIs9aFpVEV0ZgyiaKAfFtZqLI+NChl1ar5fdmRzN0vHAf2VXOrG199tD z48KTGFpEs6T0VtL659nbu7nx9sPjHX67QvnH2UZscjqwQBmGJVoZSa4aju7hZMZ5DF4 //TJJhAp4z8RZRg0Daz+RdqMjZwv7eFDtQiS8+zMta1l06TQU7DJS4owm4Uiyy9BsFhy 1Q== Received: from aptaippmta01.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com [103.229.16.4]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3hm2s787c9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 00:49:27 +0000 Received: from pps.filterd (APTAIPPMTA01.qualcomm.com [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 26T0nOnV032290; Fri, 29 Jul 2022 00:49:24 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTPS id 3hk4du4a65-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 29 Jul 2022 00:49:24 +0000 Received: from APTAIPPMTA01.qualcomm.com (APTAIPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26T0nONX032284; Fri, 29 Jul 2022 00:49:24 GMT Received: from maow2-gv.ap.qualcomm.com (maow2-gv.qualcomm.com [10.232.193.133]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 26T0nNNd032283; Fri, 29 Jul 2022 00:49:23 +0000 Received: by maow2-gv.ap.qualcomm.com (Postfix, from userid 399080) id 07BB72102E48; Fri, 29 Jul 2022 08:49:21 +0800 (CST) From: Kassey Li To: akpm@linux-foundation.org, vbabka@kernel.org Cc: Kassey Li , minchan@kernel.org, iamjoonsoo.kim@lge.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3] mm/page_owner.c: add llseek for page_owner Date: Fri, 29 Jul 2022 08:49:20 +0800 Message-Id: <20220729004920.8544-1-quic_yingangl@quicinc.com> X-Mailer: git-send-email 2.17.1 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: _FafCE0wTpoj5N29BN_IzOlcOHWC-ksS X-Proofpoint-GUID: _FafCE0wTpoj5N29BN_IzOlcOHWC-ksS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-28_06,2022-07-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 mlxlogscore=778 priorityscore=1501 suspectscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207290001 ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=QPFwBQYD; spf=pass (imf24.hostedemail.com: domain of yingangl@qualcomm.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=yingangl@qualcomm.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659055779; a=rsa-sha256; cv=none; b=JIkE4Rd6ilGsDjTju/PAV8F7WSkMNT3C01gwnO4dQL9FE1YCCmQYKDzLowsGqDXPWF69hU 5rD5jafB9npEruOTOOab+P8Q+l29mGCnoxNvhH2FXB0xJp2pa1lYuymXSc/0vLum8lM/qq 1ZLFc0U6NutiidF9mEk9mChYrZ+ixHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659055779; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:dkim-signature; bh=Ezgnbwj2vZCxnalAwrv1h3iJGqONGw5JDecLQclWyw0=; b=hW493Ri2bqWo1Qh8Ah/wcTiC5O66XhWTWxRVIrabwu7qqEkRqNlLPj8zV518Xu1qpnMHuK 1q1RH0np7HiMu22BqEJC77rDoI7zJCPCLrxXmLS7xs0JnvgvXIjBkjRBgYWwIz2Roo+MhH HP/23tGOPY9vAO1wKYMgQFg9WA71JL8= Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=QPFwBQYD; spf=pass (imf24.hostedemail.com: domain of yingangl@qualcomm.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=yingangl@qualcomm.com; dmarc=pass (policy=none) header.from=quicinc.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B2344180012 X-Stat-Signature: r8a6b3sd8dff676ysaidefzteze8mot4 X-HE-Tag: 1659055778-856510 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: There is usage to dump a given cma region page_owner instead of all page's. This change allows to specify a ppos as start_pfn by fseek. Any invalid ppos will be skipped, so it did not broken the origin dump feature. Signed-off-by: Kassey Li --- mm/page_owner.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index e4c6f3f1695b..231b1877af99 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -497,8 +497,8 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) return -EINVAL; page = NULL; - pfn = min_low_pfn + *ppos; + pfn = *ppos; /* Find a valid PFN or the start of a MAX_ORDER_NR_PAGES area */ while (!pfn_valid(pfn) && (pfn & (MAX_ORDER_NR_PAGES - 1)) != 0) pfn++; @@ -561,7 +561,7 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) continue; /* Record the next PFN to read in the file offset */ - *ppos = (pfn - min_low_pfn) + 1; + *ppos = pfn + 1; return print_page_owner(buf, count, pfn, page, page_owner, handle); @@ -570,6 +570,21 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) return 0; } +static loff_t llseek_page_owner(struct file *file, loff_t offset, int whence) +{ + loff_t retval = 0; + switch (whence) { + case SEEK_CUR: + case SEEK_SET: + file->f_pos = offset; + break; + default: + retval = -ENXIO; + } + + return retval; +} + static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone) { unsigned long pfn = zone->zone_start_pfn; @@ -660,6 +675,7 @@ static void init_early_allocated_pages(void) static const struct file_operations proc_page_owner_operations = { .read = read_page_owner, + .llseek = llseek_page_owner, }; static int __init pageowner_init(void)