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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 833BFC54E71 for ; Wed, 28 Aug 2024 10:51:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C6C06B0092; Wed, 28 Aug 2024 06:51:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 177426B0093; Wed, 28 Aug 2024 06:51:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 017396B0095; Wed, 28 Aug 2024 06:51:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D37116B0092 for ; Wed, 28 Aug 2024 06:51:29 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 83A00C1E39 for ; Wed, 28 Aug 2024 10:51:29 +0000 (UTC) X-FDA: 82501337898.07.05AD6E0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 3368380005 for ; Wed, 28 Aug 2024 10:51:27 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OkBoVm++; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724842218; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zm0TwZoHc6xSTNSFjy0hnAEuUfI8PfQsywCXlruU0iM=; b=LLXVuzGD2Psnp3oRKFAMac35VomcYss2AOwN6SB0LDlKWcvBIrPHqPHCpab2SjrapkbcBA AfdiWjB8dmaMfJKHvMIUxBKXW9jDcWLMKDhA1krPmjN6BFsYJlWNZnAhlruCwm+/AOhVcu /3Q3FDJebxV3L01ERF+yMrPVsaN1PE4= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OkBoVm++; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724842218; a=rsa-sha256; cv=none; b=GFQUqaPP4u4aUm8oefj2uONgW0T6SONyHnRMsDYsSKZW5PmgDty/TOM6dANyeCKDDKPf9E 211YDgfALEMz4EWti0RO94oK1O7HiO/0qaLr4F2IGHp9i3Jj8c/v/Xnq/QlMIWW8DAxaVC rnbfCBR9B2YDT4E3VJ5HxmPlehizdyg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724842286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=zm0TwZoHc6xSTNSFjy0hnAEuUfI8PfQsywCXlruU0iM=; b=OkBoVm++XXWbqnQeGFP9mfIpaZ0l6gURA3GFLlXe5YVZC/3X+QVcOjY85v8RVNZ+pNi/pe +/Hz3tfHB5JBZCCI6+DZKRkYKpvSxlV3+8s0aTG5jsO5t+TRipwWp3rTf/izYX2SeVOWDo LjooRLIt1lUXbfjQF+6ozRgzm/005Xc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-573-1AfMZKQHNj6cr6737P_AOQ-1; Wed, 28 Aug 2024 06:51:25 -0400 X-MC-Unique: 1AfMZKQHNj6cr6737P_AOQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3717ddcae71so3740859f8f.3 for ; Wed, 28 Aug 2024 03:51:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724842284; x=1725447084; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=zm0TwZoHc6xSTNSFjy0hnAEuUfI8PfQsywCXlruU0iM=; b=LnwJQMnPEhxAmZbGqCnu/IPwlG4i/i4Qm3xt5bn31IN22FJ4s5x4CkuGPukqDrDfP+ 3zewAAVWSVGaTUHPp5A3MXBJOoD2/5aS6CpukoJRJaYgCpJnsmdxZFzTgeagwfy9Zj1B UF/866KR4o2Wz7Gi4cCD4vp8QDT9su+Gaj9QrwqjH2k+Zar8fxGFnXsqoRniQZeD5xAp G/YGKUvPAt/yUiWojvQygIc61V0yzIXjZGxDYnZvgVGGEcWamj4LYFvcfcX2DMmhjalP EkNbMjfkNzgJttdkZfIQ5FebcYpVX96McA9UWu2empYllaqhvUbzWUcvgTAiwdatuWLl 0OAw== X-Forwarded-Encrypted: i=1; AJvYcCV93NN3SlI65YM5MDhBZRVH3tpDFMYYRU38Mmoj41d3s9JJ0ooEouYXUdtoDHnSnGDhs5asZdgqwg==@kvack.org X-Gm-Message-State: AOJu0Yyxs+D53x6oS/IwMtZ0eMmR8abX2bcw1u6pQsL0lrpesyrpWEdt YB3JMPnVI12sellrhnkeQ1ZeFkFVYdzsueMLkqGnmUfzrN5MbM2QAIn/ElpMhJNFfq14s+5senk bBG81GDJVqZ5F07UhE2ygGgzw5i02T3yT35BYpNNqyccDmCpL X-Received: by 2002:a5d:5848:0:b0:368:12ef:92d0 with SMTP id ffacd0b85a97d-374968598fcmr1195321f8f.51.1724842283951; Wed, 28 Aug 2024 03:51:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfSs2XZnzcexg6U//5VRL3+QDrHSGOUjDLcCvKXnGLOuTAtx59xAGKO+RKsTr+ZC71YA49Zw== X-Received: by 2002:a5d:5848:0:b0:368:12ef:92d0 with SMTP id ffacd0b85a97d-374968598fcmr1195282f8f.51.1724842283014; Wed, 28 Aug 2024 03:51:23 -0700 (PDT) Received: from ?IPV6:2003:cb:c706:1700:6b81:27cb:c9e2:a09a? (p200300cbc70617006b8127cbc9e2a09a.dip0.t-ipconnect.de. [2003:cb:c706:1700:6b81:27cb:c9e2:a09a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3730817a5acsm15253414f8f.64.2024.08.28.03.51.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Aug 2024 03:51:22 -0700 (PDT) Message-ID: Date: Wed, 28 Aug 2024 12:51:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [LTP] [linux-next:master] [mm/migrate] b28dd7507f: ltp.move_pages04.fail To: Cyril Hrubis Cc: kernel test robot , Claudio Imbrenda , Ryan Roberts , lkp@intel.com, Vasily Gorbik , Jonathan Corbet , "Kirill A. Shutemov" , Matthew Wilcox , Linux Memory Management List , Sven Schnelle , Zi Yan , Gerald Schaefer , oe-lkp@lists.linux.dev, Andrew Morton , Christian Borntraeger , Alexander Gordeev , ltp@lists.linux.it, Janosch Frank References: <202408211026.636ade1a-oliver.sang@intel.com> <767d1908-dc30-42ae-9a8a-d2ad42a4d491@redhat.com> <8bde28af-3401-4d72-b821-d8cf01bbcd64@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBF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UCzcsstw2TAkFnMEbo9Zu9w7Kv AxBQXWeXhJI9XQssfrf4Gusdqx8nPEpfOqCtbbwJMATbHyqLt7/oz/5deGuwxgb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: gaermuzra66qr3ix8hswze6gtexwspsc X-Rspam-User: X-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MGDMTBY95WA4Fra9y0mPlMJT2v7yn7KA77o7kHbMVER1+mvdQGRhjKAsi/kDiYKuQQBY3apPu1WS1RwQ/Ij1ur/QpDGC6yxmV55H0tnQasfp9OPOrwMCkcAtYI0165R4uPwvn6+TVfufoAj/W7RyEY//ecBweqrZYM4Fn+UR3oXd1TYfImBCzQiFHlunFGF3J8IaGTlnBQ5UPaqhKW8th/oJA2a0HilEsdxlhM/KK5sAF/uMr3INpSRMoSvcl368QwgLE0fYhUr+Q0WfxFvYi4x2520FKcehMwPUte5ZCsvsL8qeOqIl2ys9f9mtja81vhlJg53yNFcFGkRd543lf1qmBZeFMUzd6xH/omjZS9di3AiGyN0nZargZkqrwUktoPVtrODt8b4P4Jsfp+l26iMSlcNoXdv1QRMJelNTGpnfbr9e5KYmVxGIVb28DX+4ykLxA== 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: List-Subscribe: List-Unsubscribe: On 28.08.24 12:37, Cyril Hrubis wrote: > Hi! >> Okay, and it even looks like the test caught the unintended change for >> "unpopulated memory", but instead we decided to change the test to >> expect the other return code ... because there was some confusion about >> "zero page". >> >> Long story short: the test needs to be fixed. > > Will do, but we need the patch to land into some kernel version first so > taht we can add the range of kernels where the kernel wrongly returns > EFAULT. > > Or alternatively if you are going to backport this to stable trees we > can revert the test change that expect -EFAULT so the test expects only > -ENOENT. > I am not yet sure if we should simply allow either -EFAULT or -ENOENT for the "nothing mapped" case in the check (below). Alternatively, I agree, wee need to have this in the kernel so we can check for versions. What would be your preference? Currently I have (WIP): From c152535cdfae194819b6df450cdc29a60f8cdb8d Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Wed, 21 Aug 2024 10:58:34 +0200 Subject: [PATCH] move_pages04: properly check for "no page mapped" and "shared zero page mapped" While the kernel commit d899844e9c98 ("mm: fix status code which move_pages() returns for zero page") fixed the return value when the shared zero page was encountered to match what was state in the man page, it unfortunately also changed the behavior when no page is mapped yet -- when no page was faulted in/populated on demand. Then, this test started failing, and we thought we would be testing for the "zero page" case, but actually we were testing for the "no page mapped" yet case, and didn't realize that the kernel commit had unintended side effects. As we are changing the behavior back to return "-ENOENT" for the "no page mapped" case, while still making keeping the shared zero page to return "-EFAULT" the test starts failing again ... The man page clearly spells out that the expectation for the zero page is "-EFAULT", and that "-EFAULT" can also be returned if "the memory area is not mapped by the process" -- which means that there is no VMA/mmap() covering that address. The man page isn't completely clear what the expected return value for the "no page mapped" case is. It documents "-ENOENT" for "The page is not present", which can be interpreted to include "there is nothing mapped" and not just "there is something, it' just simply not suitable". We'll clarify the man page soon, to be clearer that the expectation is to get "-ENOENT" in that case, like the kernel originally did. But we'll also add a note that some kernel versions will return either -ENOENT or -EFAULT. So let's test for both cases, and make sure we allow both -ENOENT and -EFAULT for the "no page mapped" case. Signed-off-by: David Hildenbrand --- .../kernel/syscalls/move_pages/move_pages04.c | 82 ++++++++++++++----- 1 file changed, 61 insertions(+), 21 deletions(-) diff --git a/testcases/kernel/syscalls/move_pages/move_pages04.c b/testcases/kernel/syscalls/move_pages/move_pages04.c index f53453ab4..f51a73b6c 100644 --- a/testcases/kernel/syscalls/move_pages/move_pages04.c +++ b/testcases/kernel/syscalls/move_pages/move_pages04.c @@ -26,13 +26,16 @@ * move_pages04.c * * DESCRIPTION - * Failure when page does not exit. + * Failure when no page is mapped or the shared zero page is mapped. * * ALGORITHM * - * 1. Pass zero page (allocated, but not written to) as one of the - * page addresses to move_pages(). - * 2. Check if the corresponding status is set to: + * 1. Pass the address of a valid memory area where no page is mapped yet + * (not read/written) and the address of the shared zero page + * (read, but not written to) as page addresses to move_pages(). + * 2. Check if the corresponding status for "no page mapped" is set to + * either -ENOENT or -EFAULT. + * 3. Check if the corresponding status for "shared zero page" is set to: * -ENOENT for kernels < 4.3 * -EFAULT for kernels >= 4.3 [1] * @@ -64,10 +67,11 @@ #include "test.h" #include "move_pages_support.h" -#define TEST_PAGES 2 +#define TEST_PAGES 3 #define TEST_NODES 2 #define TOUCHED_PAGES 1 -#define UNTOUCHED_PAGE (TEST_PAGES - 1) +#define NO_PAGE (TEST_PAGES - 1) +#define ZERO_PAGE (NO_PAGE - 1) void setup(void); void cleanup(void); @@ -89,12 +93,12 @@ int main(int argc, char **argv) int lc; unsigned int from_node; unsigned int to_node; - int ret, exp_status; + int ret, exp_zero_page_status; if ((tst_kvercmp(4, 3, 0)) >= 0) - exp_status = -EFAULT; + exp_zero_page_status = -EFAULT; else - exp_status = -ENOENT; + exp_zero_page_status = -ENOENT; ret = get_allowed_nodes(NH_MEMS, 2, &from_node, &to_node); if (ret < 0) @@ -106,6 +110,7 @@ int main(int argc, char **argv) int nodes[TEST_PAGES]; int status[TEST_PAGES]; unsigned long onepage = get_page_size(); + char tmp; /* reset tst_count in case we are looping */ tst_count = 0; @@ -114,13 +119,30 @@ int main(int argc, char **argv) if (ret == -1) continue; - /* Allocate page and do not touch it. */ - pages[UNTOUCHED_PAGE] = numa_alloc_onnode(onepage, from_node); - if (pages[UNTOUCHED_PAGE] == NULL) { - tst_resm(TBROK, "failed allocating page on node %d", + /* + * Allocate memory and do not touch it. Consequently, no + * page will be faulted in / mapped into the page tables. + */ + pages[NO_PAGE] = numa_alloc_onnode(onepage, from_node); + if (pages[NO_PAGE] == NULL) { + tst_resm(TBROK, "failed allocating memory on node %d", + from_node); + goto err_free_pages; + } + + /* + * Allocate memory, read from it, but do not write to it. This + * will populate the shared zeropage. + */ + pages[ZERO_PAGE] = numa_alloc_onnode(onepage, from_node); + if (pages[ZERO_PAGE] == NULL) { + tst_resm(TBROK, "failed allocating memory on node %d", from_node); goto err_free_pages; } + /* Make the compiler not optimize-out the read. */ + tmp = *((char *)pages[ZERO_PAGE]); + asm volatile("" : "+r" (tmp)); for (i = 0; i < TEST_PAGES; i++) nodes[i] = to_node; @@ -135,20 +157,38 @@ int main(int argc, char **argv) tst_resm(TINFO, "move_pages() returned %d", ret); } - if (status[UNTOUCHED_PAGE] == exp_status) { + switch (status[NO_PAGE]) { + case -ENOENT: + case -EFAULT: + /* + * Before 4.3, the kernel returned -ENOENT. With 4.3 + * that behavior was changed by accident to return + * -EFAULT for some mapping types (including anonymous + * memory we use here). Newer kernels are expected to + * change that behavior again back to -ENOENT. + */ tst_resm(TPASS, "status[%d] has expected value", - UNTOUCHED_PAGE); + NO_PAGE); + break; + default: + tst_resm(TFAIL, "status[%d] is %s, expected %s or %s", + NO_PAGE, + tst_strerrno(-status[NO_PAGE]), + tst_strerrno(ENOENT), tst_strerrno(EFAULT)); + } + + if (status[ZERO_PAGE] == exp_zero_page_status) { + tst_resm(TPASS, "status[%d] has expected value", + ZERO_PAGE); } else { tst_resm(TFAIL, "status[%d] is %s, expected %s", - UNTOUCHED_PAGE, - tst_strerrno(-status[UNTOUCHED_PAGE]), - tst_strerrno(-exp_status)); + ZERO_PAGE, + tst_strerrno(-status[ZERO_PAGE]), + tst_strerrno(-exp_zero_page_status)); } err_free_pages: - /* This is capable of freeing both the touched and - * untouched pages. - */ + /* This is capable of freeing all memory we allocated. */ free_pages(pages, TEST_PAGES); } #else -- 2.46.0 -- Cheers, David / dhildenb