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 DBC59EB64DC for ; Wed, 28 Jun 2023 10:49:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A94A8D0006; Wed, 28 Jun 2023 06:49:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 659858D0001; Wed, 28 Jun 2023 06:49:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 521728D0006; Wed, 28 Jun 2023 06:49:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 452E48D0001 for ; Wed, 28 Jun 2023 06:49:19 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 14B6DC0D20 for ; Wed, 28 Jun 2023 10:49:19 +0000 (UTC) X-FDA: 80951834838.11.0E7F5A5 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf07.hostedemail.com (Postfix) with ESMTP id ADD5140016 for ; Wed, 28 Jun 2023 10:49:15 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=k39ewVsj; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf07.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687949355; 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=ob6btjFSuorpXhAULR64dCoUJky5COL+1vkFRVIp60k=; b=34526XQsVBLmWCx+oeY9fFARVT2mnUW8Y3ZKg0iXGqhIwTgYkRzDJVJPO4mwtZ7/WGx7EC YbUJi1z+f9bXYd09SzevmlzjD95HSThtKXUrGCSZ73W1e4QRmd436ednBjN1ip7uo2y+OL aN0Wg8/b//9npyX2KsY+knw3DRHbuY4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=k39ewVsj; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf07.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687949355; a=rsa-sha256; cv=none; b=FOYSmNw4QkD8mjRuzKP9MlrlBCbnWs4D4c1N8KIflKwgsbJN4Lm3dN3E9+mfe4ZIA7J2rG IfzZmwzL8x+G+6i8XPhzIvWC9FbHVWmqHgv0cSDKCaTtYqwYBhluK5Bb+WUlOxB0tcnIFg FanpfMNgzlSUDnjPnN0+CXE+IbsJ010= Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SAcAFx013623; Wed, 28 Jun 2023 10:49:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=ob6btjFSuorpXhAULR64dCoUJky5COL+1vkFRVIp60k=; b=k39ewVsjxftSNiqLjE+GUnZ+zR1ggIw/vL+D9hS+mIkhWl9tSRueMOfeV30mAs02tXET 3O36b6jri0f7r55Eoi35w7qhbXnqNZIYO7GJ7E+FHrt5tY3TUb4cHcDCRITdWJPxQaFq wGpz7xwPL96ESgcccjcoUfg2XiI8sy0BEMNQgv9e0+3nO99Y2/+qzAkugQkMAhFM8vw+ vA2Wqy94pA9UEy2XPUOiTIn3A21DGcn191MR8TJnx/2VOPL47ci9KZJ3XXq53oYe83m+ zw45v+74j4w4gTpVqdOf6R3bYAacmejQCjxq/7NeOloH9qJtscDx46aEFvmiwyjuFRFX ag== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rg9pb174c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 10:49:09 +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 35SAn7wH021484 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 10:49:08 GMT Received: from [10.214.66.119] (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 03:49:04 -0700 Message-ID: <65ce241e-8614-b669-cd20-b315c30bd794@quicinc.com> Date: Wed, 28 Jun 2023 16:19:01 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH V2] mm: madvise: fix uneven accounting of psi Content-Language: en-US To: Pavan Kondeti CC: , , , , , , References: <1687861992-8722-1-git-send-email-quic_charante@quicinc.com> From: Charan Teja Kalla In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit 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-GUID: 7x2JTTw-XtGP98JK4zzSAnneisrtiQ1e X-Proofpoint-ORIG-GUID: 7x2JTTw-XtGP98JK4zzSAnneisrtiQ1e 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_06,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 mlxlogscore=588 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280094 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: ADD5140016 X-Stat-Signature: ku95qy58xppyt998k5gcbe5yjke4xgqn X-Rspam-User: X-HE-Tag: 1687949355-819775 X-HE-Meta: U2FsdGVkX19BaAavwib7Kx7J7uNrdky2BeKUP4ij0LpAFaMrMUAGRPypJ0vXTxZVTLjlFienW7LlX1YF8zMqu9nRC4IXvMfY37p98KLFurYICAuDZJGR2FyX35+gw/GwxH7wfAlmUr/2k2Sa04sJraI/g5bksA27T88Gpd5ZiFxtVWgVb+kSa8cu084Hd9cZN+NVu3Lml95DCuXfvhMWaeNsBhjJtfgoGOXAAIgjDmUFmXgipAvqlvlmXVuCKbD4W83SB17EYZVfahX7KV2sTZ9jNdrurzXz6DFKeenloT+l6aZ0bvNmQe2mxUabzfVzj2oizZSd6bMcgypeWUSh2F6OQe1dk0mwERrJmbWATUIPmkX8N/VpkL5PYhx4nSXRkV11CmL/u641bR/rBvpCpdF7Jff6+wkWTp5QGUo7/Q9We0sy2F2Pr6BXpclLIxkgXYUjhzOCHy/FfmHotLCSpeknDHV5kbiWKXQRgWftRw/uRTg99S3rcXx3klnSEW1QL8fTX96P6rdbUl7JfPsJrCdrU+Gv8zJh06ytjZd+bNlZCPFUG1dMhlhvYsdtO+wZZkr0mWGkx5UiLWyNWZH/7Cq8HJ1rW+X0NzcbP6cLz2FmHOwqx7d7NSF1CJw2Qs3jRpeHFI6zjCWDZMYrdtGEkWqVfrzWG5Vpy0G9lP88Hw5SEASSJbB0dUaVTnmyv11oXeWSPlAqThDWPVMHUyVY4jVtJzgadb2e0MytIhryLsl3VOURr9j6n32nFu+FOTysEl4tet9uqGt+IUEz6Cet0MNLF517RsVSjMDYpgWaBWfG1KSHlXd1n64oYT70EhfgYVYW+Bn0bTUn/fgPvdGZPzC7UdS/rw0nbndJ1itKRq+b+LcGpfLateIIFu1o4gdeCAEyuxenMLbLOzuLZA8LcDoT7XMSF1ohTIHDRGj5YICBNUIVy8Dvj+p5cHSgnRW5XcaWkDTrk6Yynu7Te4m kIu5I2xu h1Phr3Z4bhvF0FzJd2QAOYaZbxpu1iqdZZFmG9/mnv98MrzsyY1AkaHj15mBwkl3PndqqyDsi0+ZkBQpm+xnBscQkZVHkjdXk793epz1Z0Z4Ow+YflZVW57tcNROGLw2oTKgJ+GpgVrgLymAPrWeQ43rHKa6ISabb3LVRGFT4KRxUGFJY4RXuvot9hRuVnDmeNu/6Kqi3tVOhUZxydy0snmYqWrPwKM2rrkAu3JCza3kbYTKWh7D8wYPLy1f8xCWX3qJ5lMIJAzV2I3MDrGg7DCWGgrwlhoxQw0ShP6D4MgcIloO/HyC6//RC/ApbdaD0+uA9+xiiSWEgI2p12BnIUhFKv/Vlk8afC/o4 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: 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. >> 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: 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. 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. [1]https://lore.kernel.org/all/20230605180013.GD221380@cmpxchg.org/