Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1442376imj; Sun, 17 Feb 2019 06:04:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ4aWqphTFzaOhc+yHxjwRda9/5dZIqWSdnF8b04o2tUics4CMKfcOu37TuhKl6TXrDRwNe X-Received: by 2002:a63:9149:: with SMTP id l70mr14324894pge.65.1550412257134; Sun, 17 Feb 2019 06:04:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550412257; cv=none; d=google.com; s=arc-20160816; b=zdLhTWNNi15tOocb3TtEJHvibvJVEiL4QmDTtdUheDtDdQ32oPGP8xuIHmWVMF7H2j +nyP3/4vApvwnpW6EC0mh00ayfjVBBHSV53I0AtbQ8ASvEVxFJTl9sUp+6dMs6pmdswT xa80dHK/cqNBd4Vb0GwPro5c1ToRosPPDHgYLqlrIPhxCqAUeBK1rJI3WISH2r7nF32M p5q3OMtGriDUR9fLQ0hhcU4v6cGFIE/ffSSnq9JGCSquTqevCvkvP25qTRZXMrb92Ndg Ar7aI0dE2JgpdtmkXlZxCqpUb8Bl90Cw9TYPE/1NYTMhi7gFBJMZaHmgSDt2w4Og8MST bJww== 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:dkim-signature; bh=rXiUAXlA4Y4NVU1+nGtiu2iiqqDtjUNA9mpoGknFqWQ=; b=fJTYWKFPgKBShvCUJqDm28R78VtMe5g5Hze7bzvW9HpkE9JMT7QByFVoDQ439C3WYD ifkLnTgdABEglFkM5ej3RBhw0GSsKBEK6PumnPjDtp3LfZtMMyzWE+Pzyf46TyXoMyXi D8JmjAjmnGxpQ2+pfEvBpEB5S+CDlygc0qLT1nMoBVw7tcFNqrNMk3Etwt4APNXay3J8 2XAYX8JKdmeeF9Qhmwfk0/ziGlQAW0SLHSAPkq6cAb6iREqDQSq7rVb+uWObRarmNaNh 2vrwi9mUGG5eeFti2M5MMT4Yd70Kd6sb8iZSw8z8JeyHxij8zx9sw17k+oznUjh+Lnr4 ewGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bILEhpIU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g132si11095244pfb.23.2019.02.17.06.04.00; Sun, 17 Feb 2019 06:04:17 -0800 (PST) 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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bILEhpIU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728576AbfBQL3s (ORCPT + 99 others); Sun, 17 Feb 2019 06:29:48 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:49630 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbfBQL3r (ORCPT ); Sun, 17 Feb 2019 06:29:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rXiUAXlA4Y4NVU1+nGtiu2iiqqDtjUNA9mpoGknFqWQ=; b=bILEhpIUWBFNWSR42Wf71Z99F AhGCHBIy/mlttSXoA1pWjgcAeH3AhOiAeg0yN7/YCU8hODtO/MYWkwW0jN/dbsttWYCYg3QuC8CFF uCeaspFD090sg7VcupXePFXHnDcCkLYG1gNKy/QtXP5MiPgpr6fFck+BRYN/69StopET93VAeQFFt 3+2iDoxJcjncSU6R0++wShu3sMBLEZSxTKOytpXkzstjlMtZ5PybcJN6/KjtjlL0Uf2/KlcU/HCCM xCQgcLxIOFtUhrmOd5tUn+c//WQIYteh9BEp85M8HPNtrZ9pQgx2tfHjaah81uUelMvz/4PDYnD1q isJcGcoqg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvKdm-0004aK-8D; Sun, 17 Feb 2019 11:29:46 +0000 Date: Sun, 17 Feb 2019 03:29:46 -0800 From: Matthew Wilcox To: ziy@nvidia.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Hansen , Michal Hocko , "Kirill A . Shutemov" , Andrew Morton , Vlastimil Babka , Mel Gorman , John Hubbard , Mark Hairgrove , Nitin Gupta , David Nellans Subject: Re: [RFC PATCH 01/31] mm: migrate: Add exchange_pages to exchange two lists of pages. Message-ID: <20190217112943.GP12668@bombadil.infradead.org> References: <20190215220856.29749-1-zi.yan@sent.com> <20190215220856.29749-2-zi.yan@sent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190215220856.29749-2-zi.yan@sent.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 15, 2019 at 02:08:26PM -0800, Zi Yan wrote: > +struct page_flags { > + unsigned int page_error :1; > + unsigned int page_referenced:1; > + unsigned int page_uptodate:1; > + unsigned int page_active:1; > + unsigned int page_unevictable:1; > + unsigned int page_checked:1; > + unsigned int page_mappedtodisk:1; > + unsigned int page_dirty:1; > + unsigned int page_is_young:1; > + unsigned int page_is_idle:1; > + unsigned int page_swapcache:1; > + unsigned int page_writeback:1; > + unsigned int page_private:1; > + unsigned int __pad:3; > +}; I'm not sure how to feel about this. It's a bit fragile versus somebody adding new page flags. I don't know whether it's needed or whether you can just copy page->flags directly because you're holding PageLock. > +static void exchange_page(char *to, char *from) > +{ > + u64 tmp; > + int i; > + > + for (i = 0; i < PAGE_SIZE; i += sizeof(tmp)) { > + tmp = *((u64 *)(from + i)); > + *((u64 *)(from + i)) = *((u64 *)(to + i)); > + *((u64 *)(to + i)) = tmp; > + } > +} I have a suspicion you'd be better off allocating a temporary page and using copy_page(). Some architectures have put a lot of effort into making copy_page() run faster. > + xa_lock_irq(&to_mapping->i_pages); > + > + to_pslot = radix_tree_lookup_slot(&to_mapping->i_pages, > + page_index(to_page)); This needs to be converted to the XArray. radix_tree_lookup_slot() is going away soon. You probably need: XA_STATE(to_xas, &to_mapping->i_pages, page_index(to_page)); This is a lot of code and I'm still trying to get my head aroud it all. Thanks for putting in this work; it's good to see this approach being explored.