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 4593CC54E41 for ; Sat, 24 Feb 2024 20:33:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4F1F6B00C3; Sat, 24 Feb 2024 15:33:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FF5F6B00C4; Sat, 24 Feb 2024 15:33:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A0126B00C5; Sat, 24 Feb 2024 15:33:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 779F36B00C3 for ; Sat, 24 Feb 2024 15:33:39 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4968D1A026A for ; Sat, 24 Feb 2024 20:33:39 +0000 (UTC) X-FDA: 81827848158.08.691D24A Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf15.hostedemail.com (Postfix) with ESMTP id 89047A0004 for ; Sat, 24 Feb 2024 20:33:37 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=X3Wygncn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708806817; 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=QcEB/B/u9FuYrsGK1/CrqSDGAOGwcMBuWBx3Xthh5/I=; b=3VjizwxWloRAE0mUy+skbFp7OdUIrB3VNpeRYVWaYU+nCieksJV5D9kN3dyRmvjYOzP46b beGEwHU9vrjTF3PIPwJsNtuP/LsPnnVN7cO5UPmmPJap6Ll6awBrg3SPZyQ5Tq65pWyUUB 4XHWrVv+mb4i94WSlvST/vNw3cPUr3k= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=X3Wygncn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708806817; a=rsa-sha256; cv=none; b=pnKHmg4CMG7oDFhFBtUuH3gda2avxgUa5NUD/JjNZQUy3wXatbJSzG1M24I/ovGvum8OSL IiueTTwQM5YnufDiwNrisCVclZQWBG/lTU+3cQFI5z0LJg59Pe7QX6ymA4plO0X7WtDNW3 s8dmcY0sGDkMkV6lH9RFLAZEwEM9FqQ= Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-dc6e080c1f0so1414604276.2 for ; Sat, 24 Feb 2024 12:33:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708806816; x=1709411616; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QcEB/B/u9FuYrsGK1/CrqSDGAOGwcMBuWBx3Xthh5/I=; b=X3WygncndLG2jiaOUjRn+QczroLz7e+ULL4yES5FFaNSH370eK8KXfPAbpun7MfgEC NGrAtTbZbZGrQfa/nvVeruLtj+mPH4quAEhYGCxzCRQ/C3chF20LAX6P5UGV5Wt679E2 /m6oHDAKKXN6vptk4pzh9DYKz4h8kQxl/suvOIeIZ8Lpb/Cvay5rr0OUdaZyfdySk8vq OmjqdhlcAcO5WE/PBJ5popeLbaFciid9QYowpwGbkuerUEylvIdsxo6XvKwo/2f+Ikcn T1PQzm9adfBzigO8woAoMqyPFrZCzKMqTc3UUx9aMPncqksLNujrZpX7rg2gQg8uQwj4 PDXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708806816; x=1709411616; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QcEB/B/u9FuYrsGK1/CrqSDGAOGwcMBuWBx3Xthh5/I=; b=qVLXwSSgo5SDvgbg2wLe1ER1tyY8v9pjtrXbBmazz+TqMsTRpfiUC4qfdJkJin++E7 fqgaufMDJjUICmeSSA/ZzL2PBVBU6yYRnTJDzWJ4qWWTZ0ItV6NwEBkgpCpJfcyvFG7Q toQVGu1KrUHkBelfxgf0CnYuWo9MZaDJsBnGRmpW5c1G59xLfyVLRWohpFPDEugWk5IV K2R898+AyCtWqu1ORTBPCOTIw92DR7jR5Jjh3e5X2jBoCmIssnhtTugFtD+I5w+tvMpu fMi/jSXc6LBJEjriuTwgM8/evYmHlL/Yun8K2xeYAspXJK70mAIFi7MeBMFkyOoFPQWY rAYg== X-Forwarded-Encrypted: i=1; AJvYcCVAuXaY1MzBwRVkaUKz8jHGBPgvclXrsmVowt7g5hV+vgdEZ6fH/M+XTM0/WlTX+IFaZeIbxLI059EWe9aGOGXKQqc= X-Gm-Message-State: AOJu0Yxf+WQ/Hk9xJJFPV0pNv6iP2bzwb3utsnrJKbKpK72fQYAl0jgA vGpvqqFn099/gLOLrOP+Huxn+sQ2fvWbE1EAAYTUb4CqAKbX2VibeyK4C0uTOZDvTwvNhnp8xOt gNqpzKEGV8MMjBbyqIHA34ioTN4A= X-Google-Smtp-Source: AGHT+IHVYeG4sdxyYLY07ymIs/jw3wT3riBpDFnsIG97UyYCih8PQUJ+OgjP21HKGNOKC9IYaojcfsNRV1cDDc/ZQPY= X-Received: by 2002:a81:9957:0:b0:608:7c7e:9d59 with SMTP id q84-20020a819957000000b006087c7e9d59mr3149810ywg.38.1708806816591; Sat, 24 Feb 2024 12:33:36 -0800 (PST) MIME-Version: 1.0 References: <20240224190724.45681-1-sj@kernel.org> <20240224201221.46450-1-sj@kernel.org> In-Reply-To: <20240224201221.46450-1-sj@kernel.org> From: Barry Song <21cnbao@gmail.com> Date: Sun, 25 Feb 2024 04:33:25 +0800 Message-ID: Subject: Re: [PATCH RFC] mm: madvise: pageout: ignore references rather than clearing young To: SeongJae Park Cc: Minchan Kim , akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, mhocko@suse.com, hannes@cmpxchg.org, Barry Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 89047A0004 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: zhpkse5mkuufxn4igj8kst1bfb3istxn X-HE-Tag: 1708806817-315147 X-HE-Meta: U2FsdGVkX18+I8FRhH0OrK/NMboeiVlUxGwXdmwyGKsgQWDkTaZrK0mm1H4AfTNh9hB/R3YwOLMcjIoG8vctNuYaqfnqgbqTvu31UcfvCPSTXrip6m8AzORkULs8pFVPLqVaI9hetglUwoxEJrvCGWgowxv3tkPG2eMTMzskV/giEEAXmIREBySbLS/erb8jCtLA1Cvys7oDiklu/19zvJOfwxw/00ZdM2dN+fSgUDDbd9nmojUwxw+Q/FAqNdxuwLByQx77Cbb5bMvtYVVjCDZkOh+BLXBMFWntmnxir9pGo6tosoW/l8NbXR1WabKJ5/AUO79LQD5w5WgbzRTcMEuBrqwRnSeaDA1Jhf4Uj6ep7E202UxxAH/ybCa3YUofnQdHRyozCdEExCLdWFYNSQDRGpFeD4dtmI07Fyrw+9/RM1f7w5lRzwuxqROuEHHkUqni3A9grRKKBdJx6fExNmjVOz+xc5aEuHBCLRZNH2crHfZpBreirCYcVP3DLvBYQTZl3YOal7ILGdEhyuHYl1Y7FhZkOdZkN/QRE+ziM2QNoueAXoOAuskgxUAPFbEHnxbsB79h492kSGAI9vH2XroKMWvenTOSouRwQlaVXfQB5tDBne1XuIdwuxXpzHx+dEDXlkfD/B7Uz6EqW7maoo8Iep1+RyQZadB/6mpTE3zoPVqWvNcBMpja0RahD73l02ra5o8KHgFneaGUaHsZinbpWrohaJs4kV3LPxg2G21axh00Bm4RRc88pyhIVnQUlL3AuTQ4FTI+VNAErK1My8eWv3KnCQQRQ8l7+ZlKr+OgIQX2+CNmLHm3jxaKb7x6vzlsKWnHT4Pn0ZmjnFctl6d5s22aazpipxEI1F5Q7es5P1bZJfdZwrR2WuGiAJbNV5hGWLPbuSu4qpdgDe0TfMloHGW2RHcRtOzR6Jmliy1phNh24bRiWTx/NY8C802TBBY/eKNmYtwA0yTeIqD xsZA5XDG fsHuCNVQECLQj7rP3zgugvcUnL45haxWjBU2C7tlUbRd3aMwfgxgXzxRE+XBDKRjKVAcP5OevFKdBt3m9t9yoA8qmVnh87rfpubcMURH/Fi/vh9rSP3N2HmKWH4EcYSJc+Ju5QcDosSd8U2RPNhcYd4qV4DMESKnqrt7v6KpFY/NrbKLstK3BbImwNF+2bBZzieFzfD4SKIREKdQ/ALrg0wxcpbmAeeJWm7nakT1Qb/1+nVnwxcBctcOt2rvvwTyI0AKPgVoEum2X6NCyFNjtdWjC0/wsGOS55L2RDBgyh5bLHVKDyoIX1nNMaKQ8ZpCwxhslQcq0POeE+Cy+7dwe2Ps1o57AftVHDli11Y0bEFNgAI2aR6NcUh5RdcjduIsl1mMdadQO3Gw1D3qpHYT3VmhfFsPozc4YVtw2cnuUJslY2Y6j9Rwuv3WN1w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000034, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sun, Feb 25, 2024 at 4:12=E2=80=AFAM SeongJae Park wrote= : > > On Sat, 24 Feb 2024 11:07:23 -0800 SeongJae Park wrote: > > > Hi Barry, > > > > On Sat, 24 Feb 2024 12:37:59 +0800 Barry Song <21cnbao@gmail.com> wrote= : > > > > [...] > > > > > > BTW\uff0c > > > Hi SeongJae, > > > I am not quite sure if damon also needs this, so I have kept damon as= is by > > > setting ignore_references =3D false. MADV_PAGEOUT is an explicit hin= t users > > > don't want the memory to be reclaimed, I don't know if it is true for= damon as > > > well. If you have some comments, please chime in. > > > > Thank you for calling my name :) > > > > For DAMON's usecase, the document simply says the behavior would be sam= e to > > MADV_PAGEOUT, so if we conclude to change MADV_PAGEOUT, I think same ch= ange > > should be made for DAMON's usecase, or update DAMON document. > > Thanks to Barry's nice explanation on my other reply to the patch, now I = think > the change is modest, and therefore I'd prefer the first way: Changing DA= MON's > usecase, and keep the document as is. Hi SeongJae, thanks! I actually blindly voted for keeping DAMON's behaviour but slightly updated the document as I set ignore_references to false for the DAMON case in the RFC = :-) --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -249,7 +249,7 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) put_folio: folio_put(folio); } - applied =3D reclaim_pages(&folio_list); + applied =3D reclaim_pages(&folio_list, false); cond_resched(); return applied * PAGE_SIZE; } MADV_PAGEOUT comes from userspace by a specific process to tell the kernel to reclaim its own memory(actually focus on non-shared memory as it skips folios with mapcount>1). The range is a virtual address and the app does know it doesn't want to access the range in the foreseeable future. and the affected app is itself not global= . In the DAMON case, it seems the range is the physical address. if the pa is mapped by more than one process, it seems safer to double-check in the kernel as it might affect multiple processes? Please correct me if I am wrong. > > > Thanks, > SJ > > > > > > > Thanks, > > SJ Thanks Barry