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 4DE26C433EF for ; Mon, 27 Jun 2022 03:55:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAD538E0001; Sun, 26 Jun 2022 23:55:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5CF86B0072; Sun, 26 Jun 2022 23:55:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FE138E0001; Sun, 26 Jun 2022 23:55:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7D1BD6B0071 for ; Sun, 26 Jun 2022 23:55:02 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4F6113415E for ; Mon, 27 Jun 2022 03:55:02 +0000 (UTC) X-FDA: 79622650044.20.7C5732E Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf22.hostedemail.com (Postfix) with ESMTP id 94F48C002B for ; Mon, 27 Jun 2022 03:55:01 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25R0gNTu016384; Mon, 27 Jun 2022 03:54:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : in-reply-to : references : date : message-id : mime-version : content-type; s=pp1; bh=NRWM3XMUrJSyZ/O2Lv5qvKn+WRCWKqtUnVe9+AEAUK0=; b=Ls+7abnOsxXGfICtVubAdvkagqqNv6Fwn8TzMbBQi8sgAYsqCwOWlelECtuvIxgSMJ7Z qsCfZ8zgL/nZQ9nLOYbMxkM+uKo5Z/nuXFq1oKzuy3PBsFbbzuobzhtr1cX6CNX1t64B Xy/M4ViFCVxZgLi3HXAZnW84M5XqVVarpPB4M++pVEPn/GFNP0+Buh72FZBy7V/qf1Tv ay6iBmUZTdQVRdGkCainoW0L7C7PkhDq+TtD+MWXWdG8IkA/VuOrC+hMEyt8q+m/Q/64 XzBo+aC4YIU9iIL7SBy/yLRbDRNVyrxJ023bkG3upPgLccEKpTBvhvQVzAu6tuZCiW1h 5g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gxydc58mr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Jun 2022 03:54:45 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25R3sjNM005540; Mon, 27 Jun 2022 03:54:45 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gxydc58mf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Jun 2022 03:54:45 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25R3nsmL018207; Mon, 27 Jun 2022 03:54:44 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma03dal.us.ibm.com with ESMTP id 3gwt09hjxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Jun 2022 03:54:44 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25R3shVp31916300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Jun 2022 03:54:43 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2736F7805C; Mon, 27 Jun 2022 03:54:43 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A47E7805E; Mon, 27 Jun 2022 03:54:37 +0000 (GMT) Received: from skywalker.linux.ibm.com (unknown [9.43.47.235]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 27 Jun 2022 03:54:36 +0000 (GMT) X-Mailer: emacs 29.0.50 (via feedmail 11-beta-1 I) From: "Aneesh Kumar K.V" To: Alistair Popple Cc: linux-mm@kvack.org, akpm@linux-foundation.org, Wei Xu , Huang Ying , Yang Shi , Davidlohr Bueso , Tim C Chen , Michal Hocko , Linux Kernel Mailing List , Hesham Almatary , Dave Hansen , Jonathan Cameron , Dan Williams , Jagdish Gediya Subject: Re: [PATCH v7 09/12] mm/demotion: Demote pages according to allocation fallback order In-Reply-To: <87czf06q1i.fsf@nvdebian.thelocal> References: <20220622082513.467538-1-aneesh.kumar@linux.ibm.com> <20220622082513.467538-10-aneesh.kumar@linux.ibm.com> <87czf06q1i.fsf@nvdebian.thelocal> Date: Mon, 27 Jun 2022 09:24:31 +0530 Message-ID: <87czeuzrpk.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 6hRI6CVkYr_Tgp8cz7nNMGCc0zFZDku2 X-Proofpoint-ORIG-GUID: WUbop9QQPp0OOpTTXeet1s8juEFuissD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-27_02,2022-06-24_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=972 impostorscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 phishscore=0 adultscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206270014 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656302101; 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=NRWM3XMUrJSyZ/O2Lv5qvKn+WRCWKqtUnVe9+AEAUK0=; b=GQ3iL2huqemVp8mZ2Mzlp1gMkch+y0/OxgfTapDnD8cIfzPDJO7THTZyPFNuSC2ugYXYk0 XFUAMxGg3H+YCFwtKE6/wVGJ8v0k2P3IOcoDYp8Ga5/FM1o4XvwUD+Ws2M1NSEJGlHmCPU /Gdw17sXKxIGd5Fo88DgSQBp+CHTjr0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Ls+7abnO; spf=pass (imf22.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656302101; a=rsa-sha256; cv=none; b=MkgcU2AuTPZkXP5bMT1ML5s/gD85VXG1QBy1akApT9EIJacNePw78g4YlEEpqfVOV9+6+k Q+Y4KopKp3PpTsCgVvyTzMnVfMipxrg5GcAaVeHmOkGafRKhUyaalAOlXpmMZyIB14I4du Q8kJFhrvcK0oo3MCHID/I7vAf9qfxMI= Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Ls+7abnO; spf=pass (imf22.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: k1w8nj7fbsyhhz9bf95ki7rsywsnswry X-Rspamd-Queue-Id: 94F48C002B X-HE-Tag: 1656302101-356681 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: Alistair Popple writes: > "Aneesh Kumar K.V" writes: > >> From: Jagdish Gediya > > [...] > >> -static struct page *alloc_demote_page(struct page *page, unsigned long node) >> +static struct page *alloc_demote_page(struct page *page, unsigned long private) >> { >> - struct migration_target_control mtc = { >> - /* >> - * Allocate from 'node', or fail quickly and quietly. >> - * When this happens, 'page' will likely just be discarded >> - * instead of migrated. >> - */ >> - .gfp_mask = (GFP_HIGHUSER_MOVABLE & ~__GFP_RECLAIM) | >> - __GFP_THISNODE | __GFP_NOWARN | >> - __GFP_NOMEMALLOC | GFP_NOWAIT, >> - .nid = node >> - }; >> + struct page *target_page; >> + nodemask_t *allowed_mask; >> + struct migration_target_control *mtc; >> + >> + mtc = (struct migration_target_control *)private; >> + >> + allowed_mask = mtc->nmask; >> + /* >> + * make sure we allocate from the target node first also trying to >> + * reclaim pages from the target node via kswapd if we are low on >> + * free memory on target node. If we don't do this and if we have low >> + * free memory on the target memtier, we would start allocating pages >> + * from higher memory tiers without even forcing a demotion of cold >> + * pages from the target memtier. This can result in the kernel placing >> + * hotpages in higher memory tiers. >> + */ >> + mtc->nmask = NULL; >> + mtc->gfp_mask |= __GFP_THISNODE; >> + target_page = alloc_migration_target(page, (unsigned long)&mtc); > > I finally managed to get a system setup to start testing some of this > out. However it quickly crashed due to the bad pointer in the above call > - you need mtc not &mtc here. I remember fixing that during earlier testing. I guess I missed to copy the change from test to my development. Thanks for testing this. I have now also tested the complete series with the above-suggested changes and did make sure we are indeed doing demotion by looking at /proc/vmstat:pgdemote_kswapd/pgdemote_direct > >> + if (target_page) >> + return target_page; >> + >> + mtc->gfp_mask &= ~__GFP_THISNODE; >> + mtc->nmask = allowed_mask; >> >> return alloc_migration_target(page, (unsigned long)&mtc); > > And here. > I will fold this changes in and send a v8 after waiting for review feedback from others. -aneesh