Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5242088rwl; Wed, 28 Dec 2022 15:33:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXu8lJubTP7kGiMbyKuYdAo78wn06kSQIvOnggY2rwLAiqVGOHrSNSHqdun3ZmddOqyGD5hY X-Received: by 2002:a17:90a:f614:b0:219:672a:42db with SMTP id bw20-20020a17090af61400b00219672a42dbmr34320010pjb.19.1672270413994; Wed, 28 Dec 2022 15:33:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672270413; cv=none; d=google.com; s=arc-20160816; b=ztGI9Q2ekbptQtSIXogx+2rY1yD2Aj/pG4uACwcDtg0n3X7k5qE4CSpEf61/wUcCVF Bv5I/R9PbBATGLTgXBjoaZ0p0uMr282nreX5vUOT0GOAWTbvoPNdsY+OXkRoeia8KYle 2nvdDRr0nZQmAMhdzCmXuNz8Feeg+lx40sIlP7kz9nDtQ8uuaZt0Fp4PYXtFWLrTnJ0U 1+jZgCoGSclVG1f9NkRLCKc5C5mtXKO+L3vyC789g6h5uT7sfQhmPycTeqjjvlUi5GoF nfSFbpZo0A6hoGOpAF2S3MqIA9r55DeAuGfZjKhTQsSa9DT5SVbZDAPwc43ntgHGKtVf G0eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=hhg4H5vvV1XzaffytI4YE8QWyeA4fbFXNKp4mhs1BxA=; b=ev0T8ST7ZX9axjqQEO3+IgRrRlHUQtxHNGCrYVoMPZcZg9tQI2m7yh2u/EcxU7y0rD PAjEKCnmMYdWQaFFNf6eF6NFPgYvmHjd/Ny4W9jvKVq7I5nYUG/m3+SjUIRxioBm5Z3a xpZ1KmXe8+04odBKS8DBh5YjPxKsgOPoWfhrTT4H3kErBX8wE7c5X7HfrbggcsjXjJ8g xXoBCZxvg3eINPbU7sjGcBroqqjVO+nDYpde8SgKLAQHvh9FNuJe0GvzMowY1Dfbyacj mrDJ2uOCLfwwCjZitHf/IKEvCVH1tbvWQofLbdMtUCj0xebaK/YzYWq3GwDL8ocR8ISB 8iHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=NCioxuAf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oo15-20020a17090b1c8f00b0021a05416404si18364496pjb.67.2022.12.28.15.33.26; Wed, 28 Dec 2022 15:33:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=NCioxuAf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231372AbiL1XWN (ORCPT + 62 others); Wed, 28 Dec 2022 18:22:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231183AbiL1XWL (ORCPT ); Wed, 28 Dec 2022 18:22:11 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80C6313F2B for ; Wed, 28 Dec 2022 15:22:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9B9ACB81913 for ; Wed, 28 Dec 2022 23:22:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E26F8C433D2; Wed, 28 Dec 2022 23:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1672269727; bh=hld9DWzesHJspBjBdWtXXwcmpnWRtXWYimDUyNVg7lU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NCioxuAfrpjY7ec504lTvTZ+IWhdxj9/I78lN61qo3KmdYRj/MGpD7SMBgOkwepEM Nw77NzcT+Km4Y3muHT1eO2fLL+92+9kY2PiCa2UPRa7Dk9ynVw870WBY7YiGrZTv87 v2OR3+8mOB7G94py+ob8315RACYrmCH0kHdxFVaI= Date: Wed, 28 Dec 2022 15:22:06 -0800 From: Andrew Morton To: Huang Ying Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zi Yan , Yang Shi , Baolin Wang , Oscar Salvador , Matthew Wilcox , Bharata B Rao , Alistair Popple , haoxin Subject: Re: [PATCH 5/8] migrate_pages: batch _unmap and _move Message-Id: <20221228152206.52435aef4072c4cad9087541@linux-foundation.org> In-Reply-To: <20221227002859.27740-6-ying.huang@intel.com> References: <20221227002859.27740-1-ying.huang@intel.com> <20221227002859.27740-6-ying.huang@intel.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 27 Dec 2022 08:28:56 +0800 Huang Ying wrote: > In this patch the _unmap and _move stage of the folio migration is > batched. That for, previously, it is, > > for each folio > _unmap() > _move() > > Now, it is, > > for each folio > _unmap() > for each folio > _move() > > Based on this, we can batch the TLB flushing and use some hardware > accelerator to copy folios between batched _unmap and batched _move > stages. > > ... > > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1027,8 +1027,32 @@ static void __migrate_folio_extract(struct folio *dst, > dst->private = NULL; > } > > +static void migrate_folio_undo_src(struct folio *src, > + int page_was_mapped, > + struct anon_vma *anon_vma, > + struct list_head *ret) > +{ > + if (page_was_mapped) > + remove_migration_ptes(src, src, false); > + if (anon_vma) > + put_anon_vma(anon_vma); > + folio_unlock(src); > + list_move_tail(&src->lru, ret); > +} > + > +static void migrate_folio_undo_dst(struct folio *dst, > + free_page_t put_new_page, > + unsigned long private) > +{ > + folio_unlock(dst); > + if (put_new_page) > + put_new_page(&dst->page, private); > + else > + folio_put(dst); > +} What do the above do? Are they so obvious that no comments are needed? > static int __migrate_folio_unmap(struct folio *src, struct folio *dst, > - int force, enum migrate_mode mode) > + int force, bool force_lock, enum migrate_mode mode) > { > int rc = -EAGAIN; > int page_was_mapped = 0; > @@ -1055,6 +1079,11 @@ static int __migrate_folio_unmap(struct folio *src, struct folio *dst, > if (current->flags & PF_MEMALLOC) > goto out; > > + if (!force_lock) { > + rc = -EDEADLOCK; > + goto out; > + } Please document the use of EDEADLOCK in this code. What does it signify? > folio_lock(src); > } >