From patchwork Mon Dec 5 19:37:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13065032 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2F8AC4332F for ; Mon, 5 Dec 2022 19:41:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234892AbiLETld (ORCPT ); Mon, 5 Dec 2022 14:41:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234742AbiLETlO (ORCPT ); Mon, 5 Dec 2022 14:41:14 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 879BE286E6 for ; Mon, 5 Dec 2022 11:37:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670269047; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=839Tn9IdUKD1bh/4wO2u5vVCxR5w23tzArKt5zK/zSI=; b=YZ0A0JnpGGAv9V+Aw2H3tVUl+qAXB/WtuKgXcGw+KXbuvXZzCAJdaZLay6O8Q73D100xOS H8wO690DirUBtFDYW5YU/mDFWeIwI4O2YCKKWo/VBnjwgd4EQc8PbEuEVqFVyl6gVUvpMm D8cMzxUBfCVDYv34mw0IPajpUakCU5M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-190-jwXJRswbMtG5Lezn7_olIw-1; Mon, 05 Dec 2022 14:37:24 -0500 X-MC-Unique: jwXJRswbMtG5Lezn7_olIw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2489686F12A; Mon, 5 Dec 2022 19:37:24 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 475E920290A5; Mon, 5 Dec 2022 19:37:22 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, David Hildenbrand , Andrew Morton , Shuah Khan , Yang Li Subject: [PATCH mm-unstable v1 1/4] mm/gup_test: fix PIN_LONGTERM_TEST_READ with highmem Date: Mon, 5 Dec 2022 20:37:13 +0100 Message-Id: <20221205193716.276024-2-david@redhat.com> In-Reply-To: <20221205193716.276024-1-david@redhat.com> References: <20221205193716.276024-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org ... we have to kmap()/kunmap(), otherwise this won't work as expected with highmem. Fixes: c77369b437f9 ("mm/gup_test: start/stop/read functionality for PIN LONGTERM test") Signed-off-by: David Hildenbrand --- mm/gup_test.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/gup_test.c b/mm/gup_test.c index 0d76d9b4bb5a..33f431e0da60 100644 --- a/mm/gup_test.c +++ b/mm/gup_test.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "gup_test.h" static void put_back_pages(unsigned int cmd, struct page **pages, @@ -297,10 +298,13 @@ static inline int pin_longterm_test_read(unsigned long arg) return -EFAULT; for (i = 0; i < pin_longterm_test_nr_pages; i++) { - void *addr = page_to_virt(pin_longterm_test_pages[i]); + void *addr = kmap_local_page(pin_longterm_test_pages[i]); + unsigned long ret; - if (copy_to_user((void __user *)(unsigned long)user_addr, addr, - PAGE_SIZE)) + ret = copy_to_user((void __user *)(unsigned long)user_addr, addr, + PAGE_SIZE); + kunmap_local(addr); + if (ret) return -EFAULT; user_addr += PAGE_SIZE; } From patchwork Mon Dec 5 19:37:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13065033 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36871C4332F for ; Mon, 5 Dec 2022 19:41:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234927AbiLETlv (ORCPT ); Mon, 5 Dec 2022 14:41:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234823AbiLETlS (ORCPT ); Mon, 5 Dec 2022 14:41:18 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED45286F6 for ; Mon, 5 Dec 2022 11:37:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670269048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=38Lo8jK2a+uHnv2nru3s1Pe1r5U79n0K0BCMSGaNAFc=; b=UzDDI9XYVqo9q5+ZxNSSvWl/U0VstYYZXrglTZMwKVHvoyDxLGNjlGp67PaNN3Fq7BKfHv gTf2Bvm2b6MoF6NQ95NYjmp7Ku4cpz5lR59SZJ9qENp41oxUsjjYyX8/Q4VDozbWeTdnHO kD++Tk8IIhRylWoqUvnrdNAy91WOydY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-591-UTDgVgLcNcCzT2vNICZE4A-1; Mon, 05 Dec 2022 14:37:26 -0500 X-MC-Unique: UTDgVgLcNcCzT2vNICZE4A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14B0B185A79C; Mon, 5 Dec 2022 19:37:26 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 852762027062; Mon, 5 Dec 2022 19:37:24 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, David Hildenbrand , Andrew Morton , Shuah Khan , Yang Li Subject: [PATCH mm-unstable v1 2/4] selftests/vm: madv_populate: fix missing MADV_POPULATE_(READ|WRITE) definitions Date: Mon, 5 Dec 2022 20:37:14 +0100 Message-Id: <20221205193716.276024-3-david@redhat.com> In-Reply-To: <20221205193716.276024-1-david@redhat.com> References: <20221205193716.276024-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The tests fail to compile in some environments (e.g., Debian 11.5 on x86). Let's simply conditionally define MADV_POPULATE_(READ|WRITE) if not already defined, similar to how the khugepaged.c test handles it. Fixes: 39b2e5cae43d ("selftests/vm: make MADV_POPULATE_(READ|WRITE) use in-tree headers") Signed-off-by: David Hildenbrand --- tools/testing/selftests/vm/madv_populate.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/vm/madv_populate.c b/tools/testing/selftests/vm/madv_populate.c index 60547245e479..262eae6b58f2 100644 --- a/tools/testing/selftests/vm/madv_populate.c +++ b/tools/testing/selftests/vm/madv_populate.c @@ -20,6 +20,13 @@ #include "../kselftest.h" #include "vm_util.h" +#ifndef MADV_POPULATE_READ +#define MADV_POPULATE_READ 22 +#endif /* MADV_POPULATE_READ */ +#ifndef MADV_POPULATE_WRITE +#define MADV_POPULATE_WRITE 23 +#endif /* MADV_POPULATE_WRITE */ + /* * For now, we're using 2 MiB of private anonymous memory for all tests. */ From patchwork Mon Dec 5 19:37:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13065034 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1581C4321E for ; Mon, 5 Dec 2022 19:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234495AbiLETlx (ORCPT ); Mon, 5 Dec 2022 14:41:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234407AbiLETlT (ORCPT ); Mon, 5 Dec 2022 14:41:19 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33623275D3 for ; Mon, 5 Dec 2022 11:37:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670269052; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eWQ4pPsBzpe6OTUvcnaLk/UT4hr86kNhRIgvcHh2HCk=; b=Vfxu6h4Ol9tHBxo1i41FgYmTo5oSIXB3v+drBMAxZtd1z8eGT1YgPSnMLBhJGH4OIlSpdF Fevq47K01nm44GmWR/VNijQ9XkMb7Fb9u/3SNPoWmzCk0lsDuNr7Dr4ehFUp/sWTwuSC+B Apsk0igJ6mzL31pOPSA/NDzKQg/LR8w= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-260-ajpONTwvN6mbx4Wv6398SA-1; Mon, 05 Dec 2022 14:37:28 -0500 X-MC-Unique: ajpONTwvN6mbx4Wv6398SA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD9F78569A4; Mon, 5 Dec 2022 19:37:27 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E57F2028CE4; Mon, 5 Dec 2022 19:37:26 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, David Hildenbrand , Andrew Morton , Shuah Khan , Yang Li Subject: [PATCH mm-unstable v1 3/4] selftests/vm: cow: fix compile warning on 32bit Date: Mon, 5 Dec 2022 20:37:15 +0100 Message-Id: <20221205193716.276024-4-david@redhat.com> In-Reply-To: <20221205193716.276024-1-david@redhat.com> References: <20221205193716.276024-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The compiler complains about the conversion of a pointer to an int of different width. Fixes: 6f1405efc61b ("selftests/vm: anon_cow: add R/O longterm tests via gup_test") Signed-off-by: David Hildenbrand --- tools/testing/selftests/vm/cow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/vm/cow.c b/tools/testing/selftests/vm/cow.c index 73e05b52c49e..26f6ea3079e2 100644 --- a/tools/testing/selftests/vm/cow.c +++ b/tools/testing/selftests/vm/cow.c @@ -650,7 +650,7 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test, } /* Take a R/O pin. This should trigger unsharing. */ - args.addr = (__u64)mem; + args.addr = (__u64)(uintptr_t)mem; args.size = size; args.flags = fast ? PIN_LONGTERM_TEST_FLAG_USE_FAST : 0; ret = ioctl(gup_fd, PIN_LONGTERM_TEST_START, &args); @@ -669,7 +669,7 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test, * Read back the content via the pin to the temporary buffer and * test if we observed the modification. */ - tmp_val = (__u64)tmp; + tmp_val = (__u64)(uintptr_t)tmp; ret = ioctl(gup_fd, PIN_LONGTERM_TEST_READ, &tmp_val); if (ret) ksft_test_result_fail("PIN_LONGTERM_TEST_READ failed\n"); From patchwork Mon Dec 5 19:37:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13065035 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 107BFC4332F for ; Mon, 5 Dec 2022 19:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234109AbiLETmE (ORCPT ); Mon, 5 Dec 2022 14:42:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234872AbiLETlY (ORCPT ); Mon, 5 Dec 2022 14:41:24 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C007760FE for ; Mon, 5 Dec 2022 11:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670269061; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TJPhHvXoEWGArXjq8wabcPZKm6Vu3pXc0PH2frV06/s=; b=FqGaicG85Q7MU07BrJ5M5+XxlSV4KwGxqfYHv0vhI/7GATcgBNBGyf1r7zjaVWIoExBwW1 aOWW2tlUM89vdBiyG2AKdB+A5zcBvk5ZGcz6RlXWtOefGQY9Ci0PSslF0Gn/fXTO5wlZC7 KuLD2NRY8HRUHdHAHANAWOu1THnlwGQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-300-_50uqGV7N52EuauiOE6EBQ-1; Mon, 05 Dec 2022 14:37:30 -0500 X-MC-Unique: _50uqGV7N52EuauiOE6EBQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A538486F12A; Mon, 5 Dec 2022 19:37:29 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 308142028E98; Mon, 5 Dec 2022 19:37:28 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, David Hildenbrand , Andrew Morton , Shuah Khan , Yang Li Subject: [PATCH mm-unstable v1 4/4] selftests/vm: ksm_functional_tests: fixes for 32bit Date: Mon, 5 Dec 2022 20:37:16 +0100 Message-Id: <20221205193716.276024-5-david@redhat.com> In-Reply-To: <20221205193716.276024-1-david@redhat.com> References: <20221205193716.276024-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The test currently fails on 32bit. Fixing the "-1ull" vs. "-1ul" seems to make the test pass and the compiler happy. Note: This test is not in mm-stable yet. This fix should be squashed into "selftests/vm: add KSM unmerge tests". Signed-off-by: David Hildenbrand --- tools/testing/selftests/vm/ksm_functional_tests.c | 4 ++-- tools/testing/selftests/vm/vm_util.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vm/ksm_functional_tests.c b/tools/testing/selftests/vm/ksm_functional_tests.c index 96644be68962..b11b7e5115dc 100644 --- a/tools/testing/selftests/vm/ksm_functional_tests.c +++ b/tools/testing/selftests/vm/ksm_functional_tests.c @@ -42,13 +42,13 @@ static bool range_maps_duplicates(char *addr, unsigned long size) for (offs_a = 0; offs_a < size; offs_a += pagesize) { pfn_a = pagemap_get_pfn(pagemap_fd, addr + offs_a); /* Page not present or PFN not exposed by the kernel. */ - if (pfn_a == -1ull || !pfn_a) + if (pfn_a == -1ul || !pfn_a) continue; for (offs_b = offs_a + pagesize; offs_b < size; offs_b += pagesize) { pfn_b = pagemap_get_pfn(pagemap_fd, addr + offs_b); - if (pfn_b == -1ull || !pfn_b) + if (pfn_b == -1ul || !pfn_b) continue; if (pfn_a == pfn_b) return true; diff --git a/tools/testing/selftests/vm/vm_util.c b/tools/testing/selftests/vm/vm_util.c index 710571902743..40e795624ff3 100644 --- a/tools/testing/selftests/vm/vm_util.c +++ b/tools/testing/selftests/vm/vm_util.c @@ -50,7 +50,7 @@ unsigned long pagemap_get_pfn(int fd, char *start) /* If present (63th bit), PFN is at bit 0 -- 54. */ if (entry & 0x8000000000000000ull) return entry & 0x007fffffffffffffull; - return -1ull; + return -1ul; } void clear_softdirty(void)