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=-1.0 required=3.0 tests=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 CB050C35242 for ; Fri, 24 Jan 2020 14:46:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9992B20704 for ; Fri, 24 Jan 2020 14:46:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9992B20704 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 1DE696B0005; Fri, 24 Jan 2020 09:46:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 18FDA6B0006; Fri, 24 Jan 2020 09:46:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A4486B0007; Fri, 24 Jan 2020 09:46:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id E7C156B0005 for ; Fri, 24 Jan 2020 09:46:46 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id A7954824556B for ; Fri, 24 Jan 2020 14:46:46 +0000 (UTC) X-FDA: 76412804412.28.able77_1e028bae7545a X-HE-Tag: able77_1e028bae7545a X-Filterd-Recvd-Size: 4148 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Jan 2020 14:46:46 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id c9so2279807wrw.8 for ; Fri, 24 Jan 2020 06:46:45 -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=d7nho88btA7XdPKueW+DP7zXBwkgUh/Agx/c+r7pFKg=; b=MbjqKjbnl5lbstGSu+9zCcKafIAJMsQ5hUd119AOIxnAFul+wf+PBDdBqPuxI92+Kl iZXqZPAyIpzjBvz8tosFOac9OdVQ5AZp2QRUNK01HK+i1f1yqehYBWNzTAkezPYA56TD rTogkSbAZLJq/IGtxvYto5fAM2a5Xvo21nz5u0Db3tGbZaVsb5AtVW2ycburO2wgo7ue zRedWrwzPp4IOtSZ9oIcF4PB9ybZSH9JkgCHQeAO5oStJwNIJM1KAAM3NnrLPscGzDm+ NrFh782EOHxGv3ifR6rLzzVJjR1Bt7oqvlvUJmajiweG/LSZrDNoUCW3DJJKB63g2n1b ua2w== X-Gm-Message-State: APjAAAVtty7+1zS/WnWw8tPC58wDj98giT0p+VQ5YqIzrNpjdt6cRfnM TQuu+a6D+3yVx31MN27bnWE= X-Google-Smtp-Source: APXvYqwy13C+hrb5rggN5Fl0X/KO2iHGJRZqQvDZIaU7Uvx2HYIxOl4AtUirvS8iwnXAGM3sw4j40A== X-Received: by 2002:a5d:44ca:: with SMTP id z10mr4758194wrr.266.1579877204963; Fri, 24 Jan 2020 06:46:44 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id b128sm7032226wmb.25.2020.01.24.06.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2020 06:46:44 -0800 (PST) Date: Fri, 24 Jan 2020 15:46:43 +0100 From: Michal Hocko To: Wei Yang Cc: akpm@linux-foundation.org, yang.shi@linux.alibaba.com, jhubbard@nvidia.com, vbabka@suse.cz, cl@linux.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [Patch v2] mm/migrate.c: also overwrite error when it is bigger than zero Message-ID: <20200124144643.GV29276@dhcp22.suse.cz> References: <20200119065753.21694-1-richardw.yang@linux.intel.com> <20200124072127.GO29276@dhcp22.suse.cz> <20200124141538.GA12509@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200124141538.GA12509@richard> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000390, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri 24-01-20 22:15:38, Wei Yang wrote: > On Fri, Jan 24, 2020 at 08:21:27AM +0100, Michal Hocko wrote: > >[Sorry I have missed this patch previously] > > > > No problem, thanks for your comment. > > >On Sun 19-01-20 14:57:53, Wei Yang wrote: > >> If we get here after successfully adding page to list, err would be > >> 1 to indicate the page is queued in the list. > >> > >> Current code has two problems: > >> > >> * on success, 0 is not returned > >> * on error, if add_page_for_migratioin() return 1, and the following err1 > >> from do_move_pages_to_node() is set, the err1 is not returned since err > >> is 1 > > > >This made my really scratch my head to grasp. So essentially err > 0 > >will happen when we reach the end of the loop and rely on the > >out_flush flushing to migrate the batch. Then err contains the > >add_page_for_migratioin return value. And that would leak to the > >userspace. > > > >What would you say about the following wording instead? > >" > >out_flush part of do_pages_move is responsible for migrating the last > >batch that accumulated while processing the input in the loop. > >do_move_pages_to_node return value is supposed to override any > >preexisting error (e.g. when the user input is garbage) but the current > > I am afraid I have a different understanding here. > > If we jump to out_flush on the test of node_isset(), err is -EACCESS. Current > logic would return this instead of the error from do_move_pages_to_node(). > Seems we don't override -EACCESS. And this is the expected logic. The unexpected behavior is the one you have fixed by this patch because err = 1 wouldn't get overriden and that should have been. -- Michal Hocko SUSE Labs