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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 8FB36C33CAA for ; Tue, 21 Jan 2020 08:42:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5C1E722522 for ; Tue, 21 Jan 2020 08:42:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C1E722522 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F25B66B0006; Tue, 21 Jan 2020 03:42:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EFD506B0007; Tue, 21 Jan 2020 03:42:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEBEA6B0008; Tue, 21 Jan 2020 03:42:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id CA0696B0006 for ; Tue, 21 Jan 2020 03:42:38 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 8FB0D824805A for ; Tue, 21 Jan 2020 08:42:38 +0000 (UTC) X-FDA: 76401000396.23.talk51_1703545f0bd52 X-HE-Tag: talk51_1703545f0bd52 X-Filterd-Recvd-Size: 4303 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Jan 2020 08:42:37 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id w5so1591692wmi.1 for ; Tue, 21 Jan 2020 00:42:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tL2ilmdXW53jOUQKDAEIqhCCGh8ZV7CKZBsB46zgNx8=; b=TcE+PB7tsMruAvsChDkaEtNj6dFTNHUlVjA2qb/Tt9tdoHwQzLLQb+8Q8ANXHqjUGr xGPtXhLY6S3uyHwgIao0GSjkE+6b56AsdDq4m+HaCu46wdNe7AIOZ7FzuCPTB/kfD+sE ejxw8VT8XHO98w5fIf4ubd3NdrnYKJjANUw8+AqpFW8uTtXIBOIPxHYeXADawb5dXeSE NYj7rLPAFdCyEeFmelDVAiNfUeg4pdoXsgUM8g4X4Iu0wC0pNbjCxrdLn+rcTsWvx83R PCmExQWitksFEAgASakee7GISA0AZnEFj3I1onMVQkCtKvjPomyKbhbGs29yCCZLOOAJ kEiA== X-Gm-Message-State: APjAAAU26cCVy+ngICBfVAvFaOgz1ZaDCp0+pm2RLvHqNNrGV5GjB8D5 ubF/nMnxiFpRRVGpHs+WHGk= X-Google-Smtp-Source: APXvYqwkW0vXjcx+70B/f17uAuyCsICIZSZL6Zn8v/NiWr8mGh8V0cKPoA4J7qp7efeu2Pi8ZAahlQ== X-Received: by 2002:a1c:a404:: with SMTP id n4mr3056679wme.109.1579596157045; Tue, 21 Jan 2020 00:42:37 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id c2sm51332826wrp.46.2020.01.21.00.42.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 00:42:06 -0800 (PST) Date: Tue, 21 Jan 2020 09:42:05 +0100 From: Michal Hocko To: Wei Yang Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, yang.shi@linux.alibaba.com Subject: Re: [PATCH 1/8] mm/migrate.c: skip node check if done in last round Message-ID: <20200121084205.GD29276@dhcp22.suse.cz> References: <20200119030636.11899-1-richardw.yang@linux.intel.com> <20200119030636.11899-2-richardw.yang@linux.intel.com> <20200120093646.GL18451@dhcp22.suse.cz> <20200120222540.GA32314@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200120222540.GA32314@richard> 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 Tue 21-01-20 06:25:40, Wei Yang wrote: > On Mon, Jan 20, 2020 at 10:36:46AM +0100, Michal Hocko wrote: > >On Sun 19-01-20 11:06:29, Wei Yang wrote: > >> Before move page to target node, we would check if the node id is valid. > >> In case we would try to move pages to the same target node, it is not > >> necessary to do the check each time. > >> > >> This patch tries to skip the check if the node has been checked. > >> > >> Signed-off-by: Wei Yang > >> --- > >> mm/migrate.c | 19 +++++++++++-------- > >> 1 file changed, 11 insertions(+), 8 deletions(-) > >> > >> diff --git a/mm/migrate.c b/mm/migrate.c > >> index 430fdccc733e..ba7cf4fa43a0 100644 > >> --- a/mm/migrate.c > >> +++ b/mm/migrate.c > >> @@ -1612,15 +1612,18 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, > >> goto out_flush; > >> addr = (unsigned long)untagged_addr(p); > >> > >> - err = -ENODEV; > >> - if (node < 0 || node >= MAX_NUMNODES) > >> - goto out_flush; > >> - if (!node_state(node, N_MEMORY)) > >> - goto out_flush; > >> + /* Check node if it is not checked. */ > >> + if (current_node == NUMA_NO_NODE || node != current_node) { > >> + err = -ENODEV; > >> + if (node < 0 || node >= MAX_NUMNODES) > >> + goto out_flush; > >> + if (!node_state(node, N_MEMORY)) > >> + goto out_flush; > > > >This makes the code harder to read IMHO. The original code checks the > >valid node first and it doesn't conflate that with the node caching > >logic which your change does. > > > > I am sorry, would you mind showing me an example about the conflate in my > change? I don't get it. NUMA_NO_NODE is the iteration logic, right? It resets the batching node. Node check read from the userspace is an input sanitization. Do not put those two into the same checks. More clear now? -- Michal Hocko SUSE Labs