Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp744812img; Fri, 22 Mar 2019 07:42:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzK3zNAFFe7uRudEd5JO0HdZtEJnkoVPpoKU2yHBoe0d95rFbad0KjrcmopyjFFkGT/R/ca X-Received: by 2002:a63:6c87:: with SMTP id h129mr9417383pgc.190.1553265754028; Fri, 22 Mar 2019 07:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553265754; cv=none; d=google.com; s=arc-20160816; b=E5Ap+M/qEtXAoR/GZJoZk6vuKhhNUHr1Td7bHJm8IJn7cSbWjGifBb2Q67s1EIeX3C Kr/Zq0Htd2nNGoite9m5nilCR7uUcUUu0rCXmZAkisP3Sckaji3+X2VqQMRk49/neJJO KWBDBrz4xwAy6u0T74ubW37yDcB5/VLWovUZInBvXGKS/zGK8RbrzJ979NgDypANFHd2 2cBR9dwbucTmnCqvHqR6UvehfWJ71M5PShi68r4q4w4sjbp3vSO4infyBfPRUqpqp8dl BzT4WQvQ5XBpWaE3BjyWnDmBy0KHS7m/qHRr7x2IPgihtJWP7iAWKrMlh8yVVk23b2Cb NVog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=2wUU8qzDB4tO837W93j0Cn/SAdFYvDZS3PORjd6Bk/c=; b=EZKTVBgJIcJEWeyYkYnQ4JDg7BFxVTkWWSUlrEXSK8DIcscdUl0fKq8jkyICyl61Iu iR9FjXDHYMsKoZfVMEB80G8E/rimivDT7bFWHhgbCv//ck1Oo8Su2Ez8m4+Ag45NwkYl e75Kp1TXZRbkJfR9knlT9Vjwucp8KccyxMgqTnQGmY/WC4R7IyEEvIiH0RtAFmrplZQC U2Uvhj+GbMalEyG26Fv06cpsSXjHmlgdF5X+Q0Xqije8BedUJV4c4qaA7v0KITa55b5w 3tFjEmzGeSNFaWsIG02sTJ6wZVaIQOt3x+e6lII2NfLiUMCa5w3FmM97JdQbm9698C0D +4cA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j11si6680127pfh.47.2019.03.22.07.42.17; Fri, 22 Mar 2019 07:42:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728992AbfCVOkV (ORCPT + 99 others); Fri, 22 Mar 2019 10:40:21 -0400 Received: from mga06.intel.com ([134.134.136.31]:53499 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727719AbfCVOkV (ORCPT ); Fri, 22 Mar 2019 10:40:21 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Mar 2019 07:40:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,256,1549958400"; d="scan'208";a="154819997" Received: from unknown (HELO localhost.localdomain) ([10.232.112.69]) by fmsmga004.fm.intel.com with ESMTP; 22 Mar 2019 07:40:19 -0700 Date: Fri, 22 Mar 2019 08:41:21 -0600 From: Keith Busch To: Zi Yan Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@lists.01.org, Dave Hansen , Dan Williams , "Kirill A. Shutemov" , John Hubbard , Michal Hocko , David Nellans Subject: Re: [PATCH 0/5] Page demotion for memory reclaim Message-ID: <20190322144120.GB29817@localhost.localdomain> References: <20190321200157.29678-1-keith.busch@intel.com> <5B5EFBC2-2979-4B9F-A43A-1A14F16ACCE1@nvidia.com> <20190321223706.GA29817@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 21, 2019 at 05:12:33PM -0700, Zi Yan wrote: > > Yes, we may not want to migrate everything in the shrink_page_list() > > pages. We might want to keep a page, so we have to do those checks first. At > > the point we know we want to attempt migration, the page is already > > locked and not in a list, so it is just easier to directly invoke the > > new __unmap_and_move_locked() that migrate_pages() eventually also calls. > > Right, I understand that you want to only migrate small pages to begin with. My question is > why not using the existing migrate_pages() in your patch 3. Like: > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index a5ad0b35ab8e..0a0753af357f 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -1261,6 +1261,20 @@ static unsigned long shrink_page_list(struct list_head *page_list, > ; /* try to reclaim the page below */ > } > > + if (!PageCompound(page)) { > + int next_nid = next_migration_node(page); > + int err; > + > + if (next_nid != TERMINAL_NODE) { > + LIST_HEAD(migrate_list); > + list_add(&migrate_list, &page->lru); > + err = migrate_pages(&migrate_list, alloc_new_node_page, NULL, > + next_nid, MIGRATE_ASYNC, MR_DEMOTION); > + if (err) > + putback_movable_pages(&migrate_list); > + } > + } > + > /* > * Anonymous process memory has backing store? > * Try to allocate it some swap space here. > > Because your new migrate_demote_mapping() basically does the same thing as the code above. > If you are not OK with the gfp flags in alloc_new_node_page(), you can just write your own > alloc_new_node_page(). :) The page is already locked, you can't call migrate_pages() with locked pages. You'd have to surround migrate_pages with unlock_page/try_lock_page, and I thought that looked odd. Further, it changes the flow if the subsequent try lock fails, and I'm trying to be careful about not introducing different behavior if migration fails. Patch 2/5 is included here so we can reuse the necessary code from a locked page context.