From patchwork Wed Apr 18 12:12:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 900081 X-Patchwork-Delegate: chrubis@suse.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.org Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40R1Jm0DqLz9s4q for ; Wed, 18 Apr 2018 22:14:47 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 583893E6C3F for ; Wed, 18 Apr 2018 14:14:45 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id C2A813E6C14 for ; Wed, 18 Apr 2018 14:13:07 +0200 (CEST) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 78AD71401142 for ; Wed, 18 Apr 2018 14:13:06 +0200 (CEST) Received: by mail-pf0-f195.google.com with SMTP id q9so822772pff.1 for ; Wed, 18 Apr 2018 05:13:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=N35ICHDWpTqWRtu5tRL04ra2fV2DaekQiKWlZYHCaZ4=; b=Rnf3sZ4dUNhY2CFltGugfyigNO7ThcgsxJusLo2V99YtkEEyP4ZnvAvOfJ/uvLs3V3 zwk40d+7wLGfFCIlUPwgRzpM1zcQROBLK0JgdFFEXp5bxX7VgrDp/F+ySerbfOeCS/X/ ezlHgIa1gPmb4FS2y7vADjC1FrMRwodRqpQAlzYIXY10vZJpwhnTLYP50cgMWTC4md9R kDuaG/MMgtazyaDmhdqAZr/n/kOnMvqD4Cmso4gwjUqIqWDjqsVMSQwZNhOtrwyUkh85 SnbC60NVy38KGBkcuTGnmVNQvLva03Ehl0hj1p1VMJto64nVO3GNTa1Vs3/EBIBfGV/n +gRQ== X-Gm-Message-State: ALQs6tCwA8nZWWC9SwGN+tfvuTnB/VBJTOzaxq0n+RkEOagWr219BaNc P/rjB1sbALxKJW/4bxSBNco= X-Google-Smtp-Source: AIpwx4+GFK5hw11dPNkrSXiQMHZQxo9cCsG/4DHI6bZCDyMLRh+T53Wm7Si/jmjYvlBQFV2I8GcQhw== X-Received: by 10.98.13.71 with SMTP id v68mr1767211pfi.69.1524053585071; Wed, 18 Apr 2018 05:13:05 -0700 (PDT) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id l8sm2312328pff.126.2018.04.18.05.13.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 05:13:03 -0700 (PDT) From: Michal Hocko To: Andrew Morton Date: Wed, 18 Apr 2018 14:12:55 +0200 Message-Id: <20180418121255.334-1-mhocko@kernel.org> X-Mailer: git-send-email 2.16.3 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.5 required=7.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it X-Mailman-Approved-At: Wed, 18 Apr 2018 14:14:40 +0200 Cc: Michal Hocko , LKML , linux-mm@kvack.org, "Kirill A. Shutemov" , Zi Yan , ltp@lists.linux.it Subject: [LTP] [PATCH] mm: Fix do_pages_move status handling X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Michal Hocko Li Wang has reported that LTP move_pages04 test fails with the current tree: LTP move_pages04: TFAIL : move_pages04.c:143: status[1] is EPERM, expected EFAULT The test allocates an array of two pages, one is present while the other is not (resp. backed by zero page) and it expects EFAULT for the second page as the man page suggests. We are reporting EPERM which doesn't make any sense and this is a result of a bug from cf5f16b23ec9 ("mm: unclutter THP migration"). do_pages_move tries to handle as many pages in one batch as possible so we queue all pages with the same node target together and that corresponds to [start, i] range which is then used to update status array. add_page_for_migration will correctly notice the zero (resp. !present) page and returns with EFAULT which gets written to the status. But if this is the last page in the array we do not update start and so the last store_status after the loop will overwrite the range of the last batch with NUMA_NO_NODE (which corresponds to EPERM). Fix this by simply bailing out from the last flush if the pagelist is empty as there is clearly nothing more to do. Fixes: cf5f16b23ec9 ("mm: unclutter THP migration") Reported-and-Tested-by: Li Wang Signed-off-by: Michal Hocko --- Hi Andrew, this is a new regression in 4.17-rc1 so it would be great to merge sooner rather than later. It is a user visible change. The original bug report is http://lkml.kernel.org/r/20180417110615.16043-1-liwang@redhat.com Thanks to Li Wang for his testing! mm/migrate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/migrate.c b/mm/migrate.c index 507cf9ba21bf..c7e5f6447417 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1634,6 +1634,9 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, current_node = NUMA_NO_NODE; } out_flush: + if (list_empty(&pagelist)) + return err; + /* Make sure we do not overwrite the existing error */ err1 = do_move_pages_to_node(mm, &pagelist, current_node); if (!err1)