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 39CB9EB64D9 for ; Thu, 29 Jun 2023 05:07:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9535A8D0002; Thu, 29 Jun 2023 01:07:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9039D8D0001; Thu, 29 Jun 2023 01:07:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CB378D0002; Thu, 29 Jun 2023 01:07:38 -0400 (EDT) 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 679618D0001 for ; Thu, 29 Jun 2023 01:07:38 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 300AB40C62 for ; Thu, 29 Jun 2023 05:07:38 +0000 (UTC) X-FDA: 80954602596.06.DD02560 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf11.hostedemail.com (Postfix) with ESMTP id D70884000A for ; Thu, 29 Jun 2023 05:07:35 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b="deoEn/Bs"; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf11.hostedemail.com: domain of quic_pkondeti@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_pkondeti@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688015256; 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:in-reply-to:references:references:dkim-signature; bh=+OUbWglMT+o+9qp921cxDrlyIoh4BAKub1E1+7ruezE=; b=eF4CjJ6gy1CIZAEBvJ7YgEfgK0TKnBbM2mzV2Z5Ew/FM+4MMl0z++mSQqIkeJd6pPpBgHJ 9xpC7gPDHlSgOVi7D2OxCaqNOb1S72fCIvst6C7BmG0WrQjqtA1qLYov5Ep/Gb4JBXlA8J BF9yiut0gUOEFiUaEDmrRRswdbT20Ps= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b="deoEn/Bs"; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf11.hostedemail.com: domain of quic_pkondeti@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_pkondeti@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688015256; a=rsa-sha256; cv=none; b=QDYtoGCIMCAeFocNOEol2JhLc2DXH+PsJHMzWWBe4c92MhsAASZlerZr72MqZXRaXibQP1 wkKe2Zrgq9DdYC2fLKAIwPqy2JwESKUzsoNAUZH2QdWGuBa5B8h+sX8meUXTre/xLMZfzi GTLvsXAzgZI63rLgSwZqdWP02zIBzqk= Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35T40OfP012625; Thu, 29 Jun 2023 05:07:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=qcppdkim1; bh=+OUbWglMT+o+9qp921cxDrlyIoh4BAKub1E1+7ruezE=; b=deoEn/BsHNKbJaY0MgoWbw6smVjqgCgjseFL4xgrRpE0rjjnUaExbArbqgot9a1aKBLk s2EplDZa5npHspl440T5ffq2e/E/S3MRv5yoOI5MWgpNyU7XBFLTyI/b2AvuNCpwLDx6 Qb6n9Qf6Lh6rFQmzyjWZHyLuCKYM5D/0tggLFWERWOO54LGwoXinpk6Tth3m82NmEjt6 81SQH5J5kw6J+9r4tdjTApHX+dzcMUVD3zm1CbSggF0Z3/pBVTI0q1OpQXMEH98mn8Gt n4eyQgPVe4bTh9gy2mAMnTZGk+YqFSC1+6XHSbJwQs7ZdKzi8wyMCcxREwpFIsjcCOAC Mg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgas2twwq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jun 2023 05:07:29 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35T57Ru7014877 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jun 2023 05:07:28 GMT Received: from hu-pkondeti-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.1118.7; Wed, 28 Jun 2023 22:07:24 -0700 Date: Thu, 29 Jun 2023 10:37:20 +0530 From: Pavan Kondeti To: Charan Teja Kalla CC: Pavan Kondeti , , , , , , , Subject: Re: [PATCH V2] mm: madvise: fix uneven accounting of psi Message-ID: <6e706e71-1594-4622-8f97-76ff08f2cdb3@quicinc.com> References: <1687861992-8722-1-git-send-email-quic_charante@quicinc.com> <65ce241e-8614-b669-cd20-b315c30bd794@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <65ce241e-8614-b669-cd20-b315c30bd794@quicinc.com> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: c9qSVPww3FN5C9dFZtcl_MhKepHFDkNl X-Proofpoint-GUID: c9qSVPww3FN5C9dFZtcl_MhKepHFDkNl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_14,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 phishscore=0 mlxlogscore=637 bulkscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 adultscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306290043 X-Rspamd-Queue-Id: D70884000A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: zy55o9z1idrskx8ws1rh6senghcabtgz X-HE-Tag: 1688015255-522768 X-HE-Meta: U2FsdGVkX19WuJqlkvqwJ8OyR3C6ciyON0M3CM/e3pkgqvKEj4UJMukqZTqp7EIsMgNLlKDVnBvVgLfTRLSe8s8UVcdWbGvivNUQbfcoeYbazeMO+uOn7Alyvt2jb/gwRvFYTbhoUSYvHqTmCaQyIBe6+rOYJUOArkmGbBL2wpd3UzJgzK+wuvN0weNU7FNi1O3z+KTJlwag6hOAph95Eqia9/jd7H27OCw5IcOEdK6U8nHuEgWQXdFoU4CFoe705AsGFbxeKN/2nppMKB/Rj90kME95rMWlplvmRzc0YR62Ku61s1IjWsZGAp3O/D1RKOhMSwUCjoAh8sCloUvx59r5GU1+MTo2RhZkUWu0NopUzQp+aBqmB2YU7Ym79LgK5XkggF8yUQ4JzvMV7yzD3JbzIjot9sQgj+w4I3SBPBwz3xoFcXgqdjO0y5UC6SLuPhEhk9+1BNsudJ/sDPApZLz1p/j1hVBSK3khAxZML/ElmEHnAboNKhugzgYUY4YZw1E5yJhZmWvUgOXnxlIanxOlQr86jp0+Yhy4KIL/Cft65bq3QSrU8hkZ7+3h7niLIsmqci9z81Rgoe5Om7pK8sa/kjkDHfqmwYqtoo2vGLmJ7TY90yyurs7V3rEISBzyguTZxOUuZYFRFoUpPNWcmf3nmuUS6EFyBXHXxGmLLGdnT55MhYLLd7K9YhR1vqsh3KkOHeKZKQgzFv1AKWprnKSJNVW7bQ2N7OPOg5z0Cps0HKgzJmz6p+8mpDiTiO/mZhKZ0KsJzZi4fPvpEbgjd/UrWg9ro8f0I6A47jShQrhDr9y0ju5ndNArhh9RLMREVZfqZ4Ng6h5UveY0+mb3oFQesJp+qiAUyAF/Ds4Pj6e3KXAd6dTvkRxo1FSmJ5AVzllHAv/n/bD8l+uCbK4gak3G57LYsnprP3sohTDd9IAMBYpUwnsijdIhv6qum4Fit0ZEBWhe78nuaKEu8uH 8cbJ7XkT cY/psAbNpgUULNwksec6je63KF01OVPq0eaK7GeYPNXetBiVupodLQan0RSzhvwFyV/sw8Do4GKJ4kcSyY3BIO/NTR8T2NZaDdqLOxtVdO1GAgLiCaRx5jCciBZQvTbOnfpTy8vXLwdnFljgt/P12yWh0GEQog3mefkcAInBq8da+kAszzr/L9FdNLXZ4Eq0mYQ/gYDsGPBs6pwfj3RwnYjxXn53PHJQCEq+xjtPawCbucLbNsJOEG0rnAEn7YcGYhY9lSB64JuS+hzI= 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 Wed, Jun 28, 2023 at 04:19:01PM +0530, Charan Teja Kalla wrote: > Hi Pavan, > > On 6/27/2023 7:26 PM, Pavan Kondeti wrote: > >> A folio turns into a Workingset during: > >> 1) shrink_active_list() placing the folio from active to inactive list. > >> 2) When a workingset transition is happening during the folio refault. > >> > >> And when Workingset is set on a folio, PSI for memory can be accounted > >> during a) That folio is being reclaimed and b) Refault of that folio. > >> > > Please help me understand why PSI for memory (I understood it as the > > time spent in psi_memstall_enter() to psi_memstall_leave()) would be > > accounted in (a) i.e during reclaim. I understand that when a working > > > > The (b) part is very clear. > > > I meant to say, for usual reclaim, PSI is accounted on a folio for both > reclaim and as well during the refault operation when Workingset is set > on a folio i.e., both a) and b) cases above. > Got it. > >> This accounting of PSI for memory is not consistent in the cases where > >> clients use madvise(COLD/PAGEOUT) to deactivate or proactively reclaim a > >> folio: > > Seems I need to be explicit here. How about the below? > > This accounting of PSI for memory is not consistent for reclaim + > refault operation between usual reclaim and madvise(COLD/PAGEOUT) which > deactivate or proactively reclaim a folio: > Looks good. > lmk for any better rephrasing? > >> a) A folio started at inactive and moved to active as part of accesses. > >> Workingset is absent on the folio thus madvise(MADV_PAGEOUT) don't > >> account such folios for PSI. > >> > >> b) When the same folio transition from inactive->active and then to > >> inactive through shrink_active_list(). Workingset is set on the folio > >> thus madvise(MADV_PAGEOUT) account such folios for PSI. > >> > >> c) When the same folio is part of active list directly as a result of > >> folio refault and this was a workingset folio prior to eviction. > >> Workingset is set on the folio thus both the operations of MADV_PAGEOUT > >> and reclaim of the MADV_COLD operated folio account for PSI. > >> > >> d) madvise(MADV_COLD) transfers the folio from active list to inactive > >> list. Such folios may not have the Workingset thus reclaim operation > >> on such folio doesn't account for PSI. > > This is not limited to madvise(PAGEOUT) right, anywhere an active page > > is reclaimed we have the same problem. For ex: damon_pa_pageout() and > > __alloc_contig_migrate_range()->reclaim_clean_pages_from_list(). > >> If that is the case, can we set mark a folio as a workingset when it is > > activated? That way, we don't have make madvise() as a special case? > I think marking the folio as a workingset when it sits on the active is > not a correct thing. For the same example you mentioned, a simple CMA > allocation will be dropping the clean pages instead of migration. PSI > accounting on refault of those pages don't reveal anything to the user. > Agreed. Thanks for the clarification. > Where as in the madvise() cases, this PSI tells the user about the type > of pages that he is working on.[1] > > BTW, damon_pa_pageout() seems a valid case above. let me fix it in the > next patch. Looks good. Thanks, Pavan