Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5436180rwb; Mon, 8 Aug 2022 19:52:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5thqRj6X3c4Qlzq4AlTLfa0SbmXD6lNJXO6glifhrEIiKdcOciVihOA2TIawEGxfiAjpEB X-Received: by 2002:a17:90b:4a8f:b0:1f5:ee3:a6a1 with SMTP id lp15-20020a17090b4a8f00b001f50ee3a6a1mr32542917pjb.149.1660013541248; Mon, 08 Aug 2022 19:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660013541; cv=none; d=google.com; s=arc-20160816; b=eX/FoBV+qaMv9zcaIPM0wTbc6r93V0k33LudtiyQT0COURUouQaHER8bYWFmO9oG63 NhXAar8isrQNW1PCkpXMiLj+zAgR/3KshbbtmIG7mPmj0s6iUqNDucceL+7PNL6kEA8O ija2lZMQ6w7qXYtgUH9m6GkLrLVIn+p1oC5Xdl+V9oSlKfVj2PYt0NGtmc+PTGv0IUP3 h4XtRZfzzkePMxhr6C2jAeSn2KZbU0qQwTt4PDDN9/uyhGTbJO4Vnxdw6CJ0zvFFP+nB BtLzvCWv9Ay2EdrFJcRcnAgx0YR8NWynOhqJZpNgyR/RPqtEYQfbTZoPBmklmknh8N+E BSig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=KGV0qPEQUODCcxLBnZ5PYXu2dwSdV+gOuAGKS5zZIKg=; b=0e0O1JTdsvv1duFMvq7YXAkGT4yZ4w+2TEdXItKqSkp+An7MIwEz9waWBayPEzkX4l dsc2Uux8DBwKzUfujqlykPOVVNDzoqW+jTAGUg9fJ+cq6T9V94D0XfnoY2CNTL+g72ww 8K/W3Ygs55kFyr120D+YTLfX+p9lV2qdOozVM+iEvUFYvb7wtN4GnzUsbimP2Gq6SIsH oZxwzmtFnIOjMoPbEXriBlVsey7ijEtJvNRoa1nTbCl9TT5BU71U/RWRm6mXJ0KAfNUF 8JROiRrzxh7pVtldxBplfsDPY+2DtBeTXNloX9xQF5jQISI0j282AgYFwLYxa8x5stBb CrTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b="WI0TIm/P"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a17090332c800b0016d3c09d205si8554579plr.107.2022.08.08.19.52.07; Mon, 08 Aug 2022 19:52:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b="WI0TIm/P"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231248AbiHICsg (ORCPT + 99 others); Mon, 8 Aug 2022 22:48:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbiHICsf (ORCPT ); Mon, 8 Aug 2022 22:48:35 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E21FBDEA0 for ; Mon, 8 Aug 2022 19:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1660013314; x=1691549314; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=KGV0qPEQUODCcxLBnZ5PYXu2dwSdV+gOuAGKS5zZIKg=; b=WI0TIm/PTZNr27sVn4GVOE5UpQ8ahFmf9cUV+2JFWWcohuOiIsudNMI9 beunJRr1WDkJJG5VrwTEWufLCDR2W+hv6j81dwQ8rY0aZBk6p4vobL/Ao 75S/S5JYdyJwLyXLj6mV8mkOFHDi2BEH81Pz0lts6hrmW9zChFo/4Q7fR 8=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.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) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) >