Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp660135ybl; Fri, 24 Jan 2020 07:15:54 -0800 (PST) X-Google-Smtp-Source: APXvYqw38CJIGMQmoiWrZvCpD/dcxaEmlAKXJZGMOX3dIqJsjq5GvEZYQM+ZUpWuqmcUMZogm5uB X-Received: by 2002:a05:6830:1016:: with SMTP id a22mr3070956otp.83.1579878953895; Fri, 24 Jan 2020 07:15:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579878953; cv=none; d=google.com; s=arc-20160816; b=fVwh14y2Yem2lpkRwASe6aG3cDEMEs3Ex32zPpoJi5DPaPaoR1ZyzJbg7jwyRZo77w o1IwIyJUjDF+iw1tMpsi0Hg3oftaaIUxAW9NRtAkDHCWMmFz4dgcle2t/SKUFMGJfNzu kWm/o6uumr6jySSrXFQBinrXSIsowTdR6ZpDixyeE2NYVmpcpeawsJA5prxHMTZLJQ/t 9gi3KgyXruvyMpJCZ4+El4ODPctrV4aVgLY2PmcFab59DV6N2Du2uh357dZh8KKlkJo+ fKz3q54HKLxnmj2zhiMg2w+VHooMs8sXYWUz5C5wGaafqLV7shTlW8FBe8aAd3vAx6/p WUXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=d7nho88btA7XdPKueW+DP7zXBwkgUh/Agx/c+r7pFKg=; b=d+KLhNfktWwR5quIIoi4zmfotVdbnGyPDXi37PeDJ9Z1a/YtGI0P3mx//yOaGWfVXy FqZUzllbRKHNdMGixW57Oxq3q6gry2pa02KGBU3DBIY2iUBGxoJ+AKZRJolMlfyEbF3+ ALerj/D9hCq0Qld8Kk4mPmNjRdny5fSa1ZZW9Vo7KVaZ28uv1WciLy+lBCMCenocEjVX ZOcjMuVuLVFSzETmuu671EbJ78XkFwQhrJatqLOCS+rqzYOwhrrSb2A/iv4CU6UJ8ml1 yIr5XOE5xJwCqrclsWZFbjiNjEaMtfWnhrSSUq0eD9ByAyjMayqBjbwBWpVetPFr7Yj8 jmgg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4si2216021oix.48.2020.01.24.07.15.41; Fri, 24 Jan 2020 07:15:53 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389856AbgAXOrR (ORCPT + 99 others); Fri, 24 Jan 2020 09:47:17 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42053 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389447AbgAXOqq (ORCPT ); Fri, 24 Jan 2020 09:46:46 -0500 Received: by mail-wr1-f65.google.com with SMTP id q6so2269658wro.9 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=DTZylmCwg5vELLX/se29ZL5QefwWb5Pxqp3i8o0pxcrnW6Rmr2QhZqBoxDKMEiH/IE IKZLYSJu28s/9NTqow02DckxtvnaagJUEXB6PuKkW282rAlFdRRFvq9/Qx0neQJKLOV7 qDsHerItTkCbURWEkgYKLaH5ArIj2G6cvEiXEB/IC1YZDjFZoIKwub/ugp0coYZ3rGuL +pNdvEP7Uu7veTffsrxb+YFoEW3ggTMhIQ/8o2AIDoR1NL3KM5N+iqDcIex2OE2FVkdr ZwL4lEIzeNTfnDQwlk8j80abWODr5VhmgQ9psmG/oNXgBH5lM/WxFPsfVKDPu+5rNIPN /QVQ== X-Gm-Message-State: APjAAAUJxIZk+cIcEaqBkDXt97480Jr74iNVox6/7QgWbQXBgrsOjOId fGMEDXsGvWWuN32TmAboHBIL4guz 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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