From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83F0E199931 for ; Thu, 16 Jan 2025 11:11:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737025863; cv=none; b=d0z30OSTfxTSvfvridj3upvtjHJR2kq8vGlb+86/hv38iPnpkRXlM5Wore9t7mp+AmABMESdnDc4qdGfQF1rY4Xjb3ePt2z5Zo95zYGGeQDeF6xferC6qKRm92kPJQV4xeA5YVtoTqf5TA1L6TWMTQrRHRoOLTPHYr+Fwm+Bgos= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737025863; c=relaxed/simple; bh=XS//482s2kICfva19b55nXEns2gVi5eA+b3KwFm3S1o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hekN72Y1l8FuLSVbGxH91o91FA5g3xQdRp58nLZqEHr9RODeQIJC0XroYDy4GEbxLPdGFFW3lQnWrWDkcTVvAwbYpr66Y0V8+AANtRGhIOMbMwaCLZTrjhHtO3LAM7gHzyRxEm/+/4ZpnjPvNKjPhajfvSzEBKbeirGpTEQ8e30= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=eZxJuL3w; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="eZxJuL3w" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50G3qQrF005703; Thu, 16 Jan 2025 11:10:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=05GiDk VQHXueFmuDGEKCgdbiFJOi2QXQHYc/NXtkQG0=; b=eZxJuL3wCiaXVXj7ARhaU0 ljcdGOW9gBcYzvb2VBmx7iYJYzbP/3HHKwlV1N+8bQWLfo2batrmmOLfiqLpWxth /faw9TGpeo9cMCPJ5FDYfnZ15R3xsme08zzeeCGchEHey/G/9guDlLnD1GGr6Yaa copcOvSDRNZRmkzYbbhOndqVZye18I8BLaaNtA6FmUb/xWV+7vaDAAr5DJHuv6DV x46B0Fjs5B9so4eSUbATuELjdvR3qkb5tbHCrpEt4Kd0rl5NiL8iRNA1ANvquyiT jdqhIg9MM9tUO93obeVZwhJHaEs7NkfyVFUni4KI+fwuu+LbDq1NM3VW54SGTrTg == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 446tkchwhb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Jan 2025 11:10:48 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 50GAxQ5Z002499; Thu, 16 Jan 2025 11:10:48 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 446tkchwh5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Jan 2025 11:10:48 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 50G9310m002738; Thu, 16 Jan 2025 11:10:46 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4443bydksc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Jan 2025 11:10:46 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 50GBAkwZ57671984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Jan 2025 11:10:46 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D3A0B58079; Thu, 16 Jan 2025 11:10:27 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 445BE58060; Thu, 16 Jan 2025 11:10:24 +0000 (GMT) Received: from [9.171.16.18] (unknown [9.171.16.18]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Jan 2025 11:10:23 +0000 (GMT) Message-ID: <7f370dd2-a1d2-4b35-ac40-0380633846fc@linux.ibm.com> Date: Thu, 16 Jan 2025 16:40:21 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC] mm/swap.c: Enable promotion of unmapped MGLRU page cache pages To: Matthew Wilcox Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Gregory Price , Yu Zhao , Ritesh Harjani , "Aneesh Kumar K . V" , David Hildenbrand , Huang Ying , Johannes Weiner References: <20250115120625.3785-1-donettom@linux.ibm.com> Content-Language: en-US From: Donet Tom In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: SqP7buP1WG16iLM_7Rk9QcdiRyFL5-qx X-Proofpoint-GUID: Dj56wYbv7PoRPMmmMtSejMOsy1vMkQC8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-16_04,2025-01-16_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 impostorscore=0 mlxscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 suspectscore=0 clxscore=1015 mlxlogscore=837 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501160082 On 1/15/25 18:55, Matthew Wilcox wrote: > On Wed, Jan 15, 2025 at 06:06:25AM -0600, Donet Tom wrote: >> An MGLRU page cache page is eligible for promotion when: >> >> 1. Memory Tiering and pagecache_promotion_enabled are enabled >> 2. It resides in a lower memory tier. >> 3. It is referenced. >> 4. It is part of the working set. >> 5. It belongs to the active list. >> For MGLRU, the youngest generation and the youngest generation - 1 >> are treated as the active list. > ... why do you only promote folios if they belong to a memcg? I missed adding non memcg folios for promotion . I will add them too. > >> +promo_candid: >> + if (!folio_test_isolated(folio) && >> + (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) && >> + numa_pagecache_promotion_enabled) { >> + memcg = folio_memcg(folio); >> + if (memcg) { >> + lruvec = mem_cgroup_lruvec(memcg, folio_pgdat(folio)); >> + gen = folio_lru_gen(folio); >> + >> + if ((gen < MAX_NR_GENS) && lru_gen_is_active(lruvec, gen)) >> + promotion_candidate(folio); >> + } > Should there be an 'else' clause here? Or should it be: > > lruvec = mem_cgroup_lruvec(memcg, folio_pgdat(folio)); > gen = folio_lru_gen(folio); > if ((gen < MAX_NR_GENS) && lru_gen_is_active(lruvec, gen)) > promotion_candidate(folio); > Yes, there should be an else block to handle the promotion of non memcg folios. Does this approach look correct to you?         } while (!try_cmpxchg(&folio->flags, &old_flags, new_flags)); + +promo_candid: +       if (!folio_test_isolated(folio) && +               (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) && +               numa_pagecache_promotion_enabled) { +               pgdat = folio_pgdat(folio); +               gen = folio_lru_gen(folio); + +               if (mem_cgroup_disabled()) +                       lruvec = &pgdat->__lruvec; +               else { +                       memcg = folio_memcg(folio); +                       lruvec = mem_cgroup_lruvec(memcg, pgdat); +               } + +               if ((gen < MAX_NR_GENS) && lru_gen_is_active(lruvec, gen)) +                       promotion_candidate(folio); +       }  }