From mboxrd@z Thu Jan 1 00:00:00 1970 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 780D6C00140 for ; Tue, 9 Aug 2022 02:48:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 069A36B0071; Mon, 8 Aug 2022 22:48:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 019D08E0003; Mon, 8 Aug 2022 22:48:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFD568E0002; Mon, 8 Aug 2022 22:48:36 -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 CE5B76B0071 for ; Mon, 8 Aug 2022 22:48:36 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A66C840DF7 for ; Tue, 9 Aug 2022 02:48:36 +0000 (UTC) X-FDA: 79778521032.26.5470BD5 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by imf04.hostedemail.com (Postfix) with ESMTP id 038854001C for ; Tue, 9 Aug 2022 02:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1660013316; x=1691549316; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=KGV0qPEQUODCcxLBnZ5PYXu2dwSdV+gOuAGKS5zZIKg=; b=qK+HB1ZDNMULkABv/tKS4MzKUduF5f7rdRvEx5ByqafXuvS92X7nNx0y APBFDItyhiYUAIBsHrO+0V7mTaA/IydmtouzJP/19bdMGBPXJJ+rYoZVm 6VPP4kv3fLoKsprFeT86fn5oUSBeiQzn/qdKFN2gqbuhExR4g4StGeQXM 0=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 08 Aug 2022 19:48:34 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2022 19:48:34 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 8 Aug 2022 19:48:33 -0700 Received: from [10.232.65.248] (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.22; Mon, 8 Aug 2022 19:48:32 -0700 Message-ID: <015e0b6d-6085-3a3a-f292-4219cafb7049@quicinc.com> Date: Tue, 9 Aug 2022 10:48:29 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0.3 Subject: Re: [PATCH v4] mm/page_owner.c: add llseek for page_owner To: "Vlastimil Babka (SUSE)" , CC: , , , References: <20220808073606.29666-1-quic_yingangl@quicinc.com> Content-Language: en-US From: Kassey Li In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit 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) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660013316; a=rsa-sha256; cv=none; b=OpsvHTqSTt3F4JXYuOzWzy3RVDwxxl5d1zvaGZh9TghxA9ObgEO4FNzL7NxZR/CsCSe1fs RGrFDOrKq/+LxxEabrUmWQhdc0/MLCfEijvr3DybuzltWXE7YzcQbGvBR0Ct/HvgTvv85j e/immyrmvvI+lhCqGQQJanNOzI96ZF0= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=qK+HB1ZD; spf=pass (imf04.hostedemail.com: domain of quic_yingangl@quicinc.com designates 199.106.114.38 as permitted sender) smtp.mailfrom=quic_yingangl@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=1660013316; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KGV0qPEQUODCcxLBnZ5PYXu2dwSdV+gOuAGKS5zZIKg=; b=OeSmZa6lcn4GfJqXBtjdlIihRFQ298KrzuuaquaRy24lyjF9R+olZJImN+s7yd+TBNrv9z FYUeza3GmPXO3yT4x7aHb2chmPGvrL86KSIDhSrLJUZU/nVYzgA5B6fcV9pvrREpI3zRe0 tHwgqa4+vxPuwHbNzo+fbiCcKv5oXJ8= X-Rspamd-Queue-Id: 038854001C Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=qK+HB1ZD; spf=pass (imf04.hostedemail.com: domain of quic_yingangl@quicinc.com designates 199.106.114.38 as permitted sender) smtp.mailfrom=quic_yingangl@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: wq7kqrm4hrkecwk81hax33rbob4cmbs7 X-HE-Tag: 1660013315-493397 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: On 8/8/2022 11:33 PM, Vlastimil Babka (SUSE) wrote: > On 8/8/22 09:36, Kassey Li wrote: >> 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. >> >> Suggested-by: Vlastimil Babka (SUSE) > > Thanks, but please change it to Vlastimil Babka > It was some mistake between me and thunderbird that it was sent from @k.o. Ok, will change it. > >> 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; > > Maybe we could still optimize the typical case a bit such that when it's 0, > we skip to min_low_pfn immediately. > >> /* 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: > > It's not correct for SEEK_CUR to behave like this, no? > Can we perhaps reuse the existing mem_lseek() ? agree. > > Also we should update Documentation/mm/page_owner.rst to document the lseek > support and that it works with a pfn. will do this in v5 patch set. > > Thanks! > >> + 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) >