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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC714C433ED for ; Fri, 9 Apr 2021 05:06:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 592E261177 for ; Fri, 9 Apr 2021 05:06:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 592E261177 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D75B16B006C; Fri, 9 Apr 2021 01:06:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D38B66B006E; Fri, 9 Apr 2021 01:06:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C00E76B0070; Fri, 9 Apr 2021 01:06:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0202.hostedemail.com [216.40.44.202]) by kanga.kvack.org (Postfix) with ESMTP id A74076B006C for ; Fri, 9 Apr 2021 01:06:47 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 654DD8248047 for ; Fri, 9 Apr 2021 05:06:47 +0000 (UTC) X-FDA: 78011643654.20.DA7EA7D Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf16.hostedemail.com (Postfix) with ESMTP id 71EAE80192D4 for ; Fri, 9 Apr 2021 05:06:46 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B480BAEE5; Fri, 9 Apr 2021 05:06:45 +0000 (UTC) Date: Fri, 9 Apr 2021 07:06:43 +0200 From: Oscar Salvador To: Yang Shi Cc: Dave Hansen , Linux MM , Linux Kernel Mailing List , Yang Shi , weixugc@google.com, Huang Ying , Dan Williams , David Hildenbrand Subject: Re: [PATCH 04/10] mm/migrate: make migrate_pages() return nr_succeeded Message-ID: References: <20210401183216.443C4443@viggo.jf.intel.com> <20210401183223.80F1E291@viggo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 71EAE80192D4 X-Stat-Signature: hrigfm7ujycfo4dhjo3wpa7xbaur6ffa Received-SPF: none (suse.de>: No applicable sender policy available) receiver=imf16; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: none/none X-HE-Tag: 1617944806-870306 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: On Thu, Apr 08, 2021 at 01:40:33PM -0700, Yang Shi wrote: > Thanks a lot for the example code. You didn't miss anything. At first > glance, I thought your suggestion seemed neater. Actually I > misunderstood what Dave said about "That could really have caused some > interesting problems." with multiple calls to migrate_pages(). I was > thinking about: > > unsigned long foo() > { > unsigned long *ret_succeeded; > > migrate_pages(..., ret_succeeded); > > migrate_pages(..., ret_succeeded); > > return *ret_succeeded; > } But that would not be a problem as well. I mean I am not sure what is foo() supposed to do. I assume is supposed to return the *total* number of pages that were migrated? Then could do something like: unsigned long foo() { unsigned long ret_succeeded; unsigned long total_succeeded = 0; migrate_pages(..., &ret_succeeded); total_succeeded += ret_succeeded; migrate_pages(..., &ret_succeeded); total_succeeded += ret_succeeded; return *total_succeeded; } But AFAICS, you would have to do that with Wei Xu's version and with mine, no difference there. IIUC, Dave's concern was that nr_succeeded was only set to 0 at the beginning of the function, and never reset back, which means, we would carry the sum of previous nr_succeeded instead of the nr_succeeded in that round. That would be misleading for e.g: reclaim in case we were to call migrate_pages() several times, as instead of a delta value, nr_succeeded would accumulate. But that won't happen neither with Wei Xu's version nor with mine. -- Oscar Salvador SUSE L3