From patchwork Tue Oct 17 13:19:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Yisheng X-Patchwork-Id: 10012007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3654160235 for ; Tue, 17 Oct 2017 13:24:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26675288AF for ; Tue, 17 Oct 2017 13:24:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B229288BF; Tue, 17 Oct 2017 13:24:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 729F2288AF for ; Tue, 17 Oct 2017 13:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WkHUgxTW5iQelCG1jRD5ZIDIw3r5oRxE1pc7gJ0EXrc=; b=lkF6QrECGqMNI0 xlnWSvrnIpau+Y4I309KQZh52OgzMv/lPqC3xD3r+1wyFyQmmG47aoDl9YzUfkKxWMaR8sdu9e4Xf yPRWoiT2ez1qPjKTsALds7tdyA/kFpRtpiddG0qqROpS4KmeddbM7Q6JwikPK8FaBEWLEq8rc4p0p HL7XXmxdtVAKsQuTyc3Ri+YQjwIMnqvZMZXe2aSG42szfy0GsEoSVFuMiq7B16a13EU9J00cJccju F/hjalIfycQBkEyzS4o9pyox8RLtJJnOK5eEgnDCPpjFE2EZphIBuFUw3IlwVDmMrBjNfeqlpeOcl d480QUxODioOC5RbJqcQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4RrM-0003CT-EA; Tue, 17 Oct 2017 13:24:40 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4RrD-000321-6d for linux-arm-kernel@lists.infradead.org; Tue, 17 Oct 2017 13:24:37 +0000 Received: from 172.30.72.58 (EHLO DGGEMS404-HUB.china.huawei.com) ([172.30.72.58]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DJF75058; Tue, 17 Oct 2017 21:23:48 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.301.0; Tue, 17 Oct 2017 21:21:34 +0800 Subject: Re: [bug report & help] arm64: ltp testcase "migrate_pages01" failed To: Will Deacon , Tan Xiaojun References: <59E49B2B.8020802@huawei.com> <59E571ED.9090106@huawei.com> <20171017092307.GB21398@arm.com> From: Yisheng Xie Message-ID: <8d412c29-6dd7-126f-1460-23bdd3415816@huawei.com> Date: Tue, 17 Oct 2017 21:19:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <20171017092307.GB21398@arm.com> X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0202.59E60464.013E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 4052984047ee916d159a1a9d58064849 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171017_062431_896749_51C1E745 X-CRM114-Status: GOOD ( 22.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: catalin.marinas@arm.com, punit.agrawal@arm.com, linux-kernel@vger.kernel.org, hanjun.guo@linaro.org, boris.ostrovsky@oracle.com, tglx@linutronix.de, "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Will, On 2017/10/17 17:23, Will Deacon wrote: > On Tue, Oct 17, 2017 at 10:58:53AM +0800, Tan Xiaojun wrote: >> I'm not sure if this is the problem on arm64 numa. What do you think ? >> By the way, this testcase can be successful in any case on x86. > > To be honest, this isn't a particularly helpful bug report. I appreciate > that a test is reporting failure, but it doesn't look like you've spent > very much effort to understand what the test is trying to do and why it > thinks it's failed to do it. All I can sensibly do with your bug report > is run the test myself, and it passes on the systems I have available. > > So, you need to: > > 1. Understand what the test is doing. > 2. Figure out which bit isn't doing what it's supposed to > 3. See if that part can be isolated to trigger the problem > > At that point, it should be possible to describe the unexpected behaviour > at a level which we can actually investigate if necessary. This test case is to test whether we should migrate successfully if user call SYSC_migrate_pages with a invalid node. eg, we should 4 node 0-3, and try to migrate to node 4. And this should return -EINVAL. however, the kernel will migrate the memory to node 0 and return ok(e.g. 0). The root cause is for nodes_subset(*new, node_states[N_MEMORY]) will return true when new = 0x10 and node_states[N_MEMORY]=0xf, MAX_NUMNODES=4. And this is common issue, and I also can reproduce at certain config on X86-64 e.g. CONFIG_NODES_SHIFT=3 and have 8 node in the system. IMO, if nbits=4, 0x0 or 0x10, 0xFF..F0 should not a subset of anything, so following patch may fix this problem: From: Yisheng Xie Date: Tue, 17 Oct 2017 20:53:55 +0800 Subject: [PATCH] bitmap: fix corner case of bitmap_subset As Xiaojun reported the ltp of migrate_pages01 will failed in system whoes has 4 node with CONFIG_NODES_SHIFT=2: migrate_pages01 0 TINFO : test_invalid_nodes migrate_pages01 14 TFAIL : migrate_pages_common.c:45: unexpected failure - returned value = 0, expected: -1 migrate_pages01 15 TFAIL : migrate_pages_common.c:55: call succeeded unexpectedly and the root cause is nodes_subset(*new, node_states[N_MEMORY]) will return true in the case like: new = 0x10 and node_states[N_MEMORY]=0xf, MAX_NUMNODES=4. Fix it by correct the corner case of bitmap_subset, which makes 0x0 or 0x10, 0xFF..F0 not a subset of bitmap when bitmap lenth is 4. Reported-by: Tan Xiaojun Signed-off-by: Yisheng Xie --- include/linux/bitmap.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 700cf5f..bc66978 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -283,6 +283,8 @@ static inline int bitmap_intersects(const unsigned long *src1, static inline int bitmap_subset(const unsigned long *src1, const unsigned long *src2, unsigned int nbits) { + if(!(*src1 & BITMAP_LAST_WORD_MASK(nbits))) + return false; if (small_const_nbits(nbits)) return ! ((*src1 & ~(*src2)) & BITMAP_LAST_WORD_MASK(nbits)); else