Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2504126rwb; Sun, 4 Sep 2022 18:02:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wL/tQFkGosr+AQN3QNMiaSvl3qeTYxptqi6jopDvxcPWtY30xkdbGR3+idXeaSXdBS2zs X-Received: by 2002:a17:907:2cd3:b0:741:550e:17ea with SMTP id hg19-20020a1709072cd300b00741550e17eamr26460863ejc.595.1662339745897; Sun, 04 Sep 2022 18:02:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1662339745; cv=pass; d=google.com; s=arc-20160816; b=fmrbHjg6v/4LDybZY8v2w8cMlueNHpRp+WqlQlGhn6xvyl+EMlM2vkM57XqIVXY79v VQTEsZ8rf9EoYTJbpimV2NAryeQj1/1R7/9Aw3KSy5aYOwkpRmYJzkbWltjLn5vY7kiF FwRNsgP3wkeB8JhO16xQ1zBdZGBDavDaiduBZEP6ibUc3/AI7r+syedL/nIuwcO+bcIM rPDrlrJXkaAGl5ZE8Y7ftbi3o5jaqc2ek/TmwkKy9oJhbdEXzRZZ9ExCDDVmucniW/jZ 9AMs3Bm+QuxTXCCfqk7/UgRdI+LJa0gpiKatpi8KA6TwDGoNNmjPjD75EuSRAARNx1xU j8xQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=Cg1V3eJNG0733B+ZazLYIO0/6lpqyf9HBMzTNkQ3ZgA=; b=a4ZPx7779t/+leG143aPGA1ykFdSSvKffECKQq388LfpdS+kJSVrnCG823J7zA6WX4 1HSKwQU5oCggCS/GoCMOX7dwyvQIL6kS7PdgFlXEBW4bR6Tl/hXLNe6U6yS/AHOXxrmL czgIlXww5xoK/YED0cTfPWAZ9/9i2fQynJlGzQiQ3FlqBcHyt/2LkS+V6+oh1uudoLaZ FFDqFTKSWWYb/7f+Sf1wj1TRsuS+XYATH9oJuaAYYFJq17aFlEddqPumIRhKn3IcWmdY IMujIG1sirOSkMTjb6tR5c/WFZ0djUXNZs3IlqSt+dtr2gCdJxAKPOZvvtK6eN5fT3tN ZCXw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=C5XSCLcr; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f9-20020a0564021e8900b00447c8bf393dsi8281848edf.229.2022.09.04.18.01.59; Sun, 04 Sep 2022 18:02:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=C5XSCLcr; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231967AbiIEAlU (ORCPT + 99 others); Sun, 4 Sep 2022 20:41:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232029AbiIEAlO (ORCPT ); Sun, 4 Sep 2022 20:41:14 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2045.outbound.protection.outlook.com [40.107.223.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2338024084 for ; Sun, 4 Sep 2022 17:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EumMnOHuS542aswXXoDkMkoO8bOGEoNhTOB65LwOgEgjq//usaV1QqTUDPu26BR+/UK0XNrSzVLzI0pGCXRBfTV99DwAYzG32JPaeU64B/c82TCu/WGM3B1Rggc1FwzSHugg6HNXrRyLXdfh1v1jMjTudQlm7T+AZjFQ8xPhLKRrMH5phi+yOnbysTV+gbBAT2F3dWN4Lfl/ADd+hB6Llvn85DA3Y8g1T2u5YjL6Puv71AwXViAiLgJLgvKbzgo3zbMbgmL7/yKx5fKxafJ1cUt5Wgpe1NenQa9s99BzE3+1eW3j6gTMhi2NCbBeQ9svgYDS5vSopgBkNSTBYR7YZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Cg1V3eJNG0733B+ZazLYIO0/6lpqyf9HBMzTNkQ3ZgA=; b=KZGBcCaUCdusDecleuKcoKfyKokXTP0FyzkyhD7LQnn/wYr0zyzBqG1w0IS8xGlSF3nv3I0pXyZWDm5J9v/kLjgnvRngMVLpxkPu7CMV9XSuFSXNXxXkr15nRK28yua0KPZ4skM2rxkJN7bTylJn+JrR7jt0ydv8YdInYu6J+L9Ae+dhsT918dttUrO9lVehh6wDqmiWlXx1eIxfvDbUWeSwea/hLH86xjv7zcVvA5hAmF19PcJhdhJgGElJZnvAeJRFPlOSV2iwr3iCp1jEpJxvlrMcyay1KdGIJF+KEbUM3kyQvJBCBbei3saJ0wbwDjRHUcyXQhnEkWi1VfuwGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cg1V3eJNG0733B+ZazLYIO0/6lpqyf9HBMzTNkQ3ZgA=; b=C5XSCLcrJdMDDUplckTr3wiRSioPDy0mHKbiNCBbACvqOGO4B4dA3hYvIv03LKu3q3Bnu6NsZWwGgFlDVdpSov2DjQacm5e5Q4mr8zXSpWTE4Y8aWEb3iC3XgkR9ZUcyGWuJ/mvQI6vqghM8jAF87AITTycJCRTGKOp7MWdDjKbKhWjFBeFB6q9RwVgGj3EJjpaD+dkeTRw/7iBvW1+bFATcUbmvrbDf+o8KRXzMBC8USsxBxsy4qJTcdcDL7i8Cp1NrOsvrDVNvTijezQGaAHmSAJQL7iVT/uH/H0YkrnzVUmmhHwjIF6W2nEKv0bOM6zAD97APfH51x6bdpIVz5g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) by SJ0PR12MB6968.namprd12.prod.outlook.com (2603:10b6:a03:47b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 5 Sep 2022 00:41:10 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::508d:221c:9c9e:e1a5]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::508d:221c:9c9e:e1a5%9]) with mapi id 15.20.5588.018; Mon, 5 Sep 2022 00:41:10 +0000 Message-ID: Date: Sun, 4 Sep 2022 17:41:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v4 4/4] selftests/hmm-tests: Add test for dirty bits Content-Language: en-US To: Alistair Popple , linux-mm@kvack.org, akpm@linux-foundation.org Cc: Peter Xu , Nadav Amit , huang ying , LKML , "Sierra Guiza, Alejandro (Alex)" , Felix Kuehling , Jason Gunthorpe , David Hildenbrand , Ralph Campbell , Matthew Wilcox , Karol Herbst , Lyude Paul , Ben Skeggs , Logan Gunthorpe , paulus@ozlabs.org, linuxppc-dev@lists.ozlabs.org References: <9f801e9d8d830408f2ca27821f606e09aa856899.1662078528.git-series.apopple@nvidia.com> <68cf1d70f3fb8ce4e3c1a4899c19df4f6c382a13.1662078528.git-series.apopple@nvidia.com> From: John Hubbard In-Reply-To: <68cf1d70f3fb8ce4e3c1a4899c19df4f6c382a13.1662078528.git-series.apopple@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SJ0P220CA0020.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::26) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9ea8ea1b-eef2-4adb-3729-08da8ed753e8 X-MS-TrafficTypeDiagnostic: SJ0PR12MB6968:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s5zyt9rwpC0OtOW1Dc3S95unokOPkDLyQ3OEr8dGvIJCXlRP4AACjxLwRJxqNaOcLPS+kEEUrN0g5MwmVF7Gupw3dYbZ8vP+P4xNs0QnCPraIH0rVJVLSywaEGiYTFeVHHo6gtBVBEkjI15A+0hKhU+5PLuZTgBJ9PP11HDR25UWLyy5hyaOk5OCwAnP9A5W+Q2bG9P8+w726nOFKLR+JFvMoaKSDk2r9DFo2vyi29QJJQ+bMQq0+OAcJzvQ781aHbdPB50/piSPa+tVl7gmiKpvKNI/JwZQbdYDTfi7L/ZAYtBXLwMBW2kei8l3jCx+jKbn327XDo6VHKpu6DQtN6zcgFET4R36AEvpeuc5rHCWxaLia3jhzU1qGE3o1QuRBtRIisw3ZMVRjRxxBYZgFUOPZd+ewRv+LikFEPEqXgkTPei1k1lXO+AoN+EbxFDe8drvjjC0X8CvstaLeLdImLKhxGDrxygjgX9MVsx3P8tc63TvbbPUqjvmioQsIfBwRANF91DgoKPHtoiy9EemkF22nr3+poa138j+Oz2bHTg/tGldlLvuFtbiU9/AVoobpSfl6PaH5DM1XBoArW3WgmwybudWSVtZvpBKk27u3Mfy0Kl8k79x9zAp3YQhmjFGVkW3PtchqNDpWjk98QI2PwAfG+o35uaxw+Y2o5et7ASeMmga85VHmDc8PNuwJy0iOCcUc2zdkbht6Q95B6RaaZA9cHxhiqOtcbWnWC8J+yfG6fnGY2iSMGZYJh9u0vrcsazWgkIon4rd0HFI/G88/GWNd9RQNr540oSsvsJE3GssQZK2uESObqCCMc4fWDoYF/83Y+yC2bslKXhuB3HmBg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB4130.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(376002)(396003)(136003)(346002)(39860400002)(366004)(8676002)(2616005)(54906003)(316002)(4326008)(66946007)(66556008)(66476007)(38100700002)(7416002)(2906002)(5660300002)(41300700001)(86362001)(36756003)(31696002)(8936002)(53546011)(26005)(186003)(83380400001)(6666004)(6486002)(6506007)(6512007)(31686004)(478600001)(14143004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aUNsem96MWozSktQcVBJRnczZzZJeUR0NFNOcituQ1dYTWRYWk1EM1o4alRG?= =?utf-8?B?cnVFeEQzNTF3cmxsMTJQU2s2bj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?B?SzhXTmtHWlRGUkhuUjFSbndQY3JwM1VVaERoL04wVU1CN05jRWxiMTkvMjRF?= =?utf-8?B?dkFMWWtVTCt4dlp0bG9uK1o2UTB6akJhb1JJSmY5MkdkVXdVRENFcjQwLzc4?= =?utf-8?B?bEJ5RWdoZ0NMR2FVRFoyMkd5LzU1ZWllNVM5bjE2RURBSVpoYkJLOEVmbUlp?= =?utf-8?B?dFE0Vm5RL3JReWhjQ3FZYUwrZVg1MGI4Z2tQN3FRbTRwaVFBSWtEemZnTGkx?= =?utf-8?Q?m7VtWOV+TyMuZFM0d8Gv1063B?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ea8ea1b-eef2-4adb-3729-08da8ed753e8 X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2022 00:41:10.5373 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: u8bSeMJNMNAPnCXjjQLlj5l+lMFqQkGuW2v4SX82aTZ/sADA0UeoeY3nrqBZmNf9hmOjvvODbMlC3LYYWzzAOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6968 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/1/22 17:35, Alistair Popple wrote: > We were not correctly copying PTE dirty bits to pages during > migrate_vma_setup() calls. This could potentially lead to data loss, so > add a test for this. > > Signed-off-by: Alistair Popple > --- > tools/testing/selftests/vm/hmm-tests.c | 124 ++++++++++++++++++++++++++- > 1 file changed, 124 insertions(+) > > diff --git a/tools/testing/selftests/vm/hmm-tests.c b/tools/testing/selftests/vm/hmm-tests.c > index 529f53b..70fdb49 100644 > --- a/tools/testing/selftests/vm/hmm-tests.c > +++ b/tools/testing/selftests/vm/hmm-tests.c > @@ -1200,6 +1200,130 @@ TEST_F(hmm, migrate_multiple) > } > } > > +static char cgroup[] = "/sys/fs/cgroup/hmm-test-XXXXXX"; > +static int write_cgroup_param(char *cgroup_path, char *param, long value) > +{ > + int ret; > + FILE *f; > + char *filename; > + > + if (asprintf(&filename, "%s/%s", cgroup_path, param) < 0) > + return -1; > + > + f = fopen(filename, "w"); > + if (!f) { > + ret = -1; > + goto out; > + } > + > + ret = fprintf(f, "%ld\n", value); > + if (ret < 0) > + goto out1; > + > + ret = 0; > + > +out1: > + fclose(f); > +out: > + free(filename); > + > + return ret; > +} > + > +static int setup_cgroup(void) > +{ > + pid_t pid = getpid(); > + int ret; > + > + if (!mkdtemp(cgroup)) > + return -1; > + > + ret = write_cgroup_param(cgroup, "cgroup.procs", pid); > + if (ret) > + return ret; > + > + return 0; > +} > + > +static int destroy_cgroup(void) > +{ > + pid_t pid = getpid(); > + int ret; > + > + ret = write_cgroup_param("/sys/fs/cgroup/cgroup.procs", > + "cgroup.proc", pid); > + if (ret) > + return ret; > + > + if (rmdir(cgroup)) > + return -1; > + > + return 0; > +} > + > +/* > + * Try and migrate a dirty page that has previously been swapped to disk. This > + * checks that we don't loose dirty bits. s/loose/lose/ > + */ > +TEST_F(hmm, migrate_dirty_page) > +{ > + struct hmm_buffer *buffer; > + unsigned long npages; > + unsigned long size; > + unsigned long i; > + int *ptr; > + int tmp = 0; > + > + npages = ALIGN(HMM_BUFFER_SIZE, self->page_size) >> self->page_shift; > + ASSERT_NE(npages, 0); > + size = npages << self->page_shift; > + > + buffer = malloc(sizeof(*buffer)); > + ASSERT_NE(buffer, NULL); > + > + buffer->fd = -1; > + buffer->size = size; > + buffer->mirror = malloc(size); > + ASSERT_NE(buffer->mirror, NULL); > + > + ASSERT_EQ(setup_cgroup(), 0); > + > + buffer->ptr = mmap(NULL, size, > + PROT_READ | PROT_WRITE, > + MAP_PRIVATE | MAP_ANONYMOUS, > + buffer->fd, 0); > + ASSERT_NE(buffer->ptr, MAP_FAILED); > + > + /* Initialize buffer in system memory. */ > + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) > + ptr[i] = 0; > + > + ASSERT_FALSE(write_cgroup_param(cgroup, "memory.reclaim", 1UL<<30)); > + > + /* Fault pages back in from swap as clean pages */ > + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) > + tmp += ptr[i]; > + > + /* Dirty the pte */ > + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) > + ptr[i] = i; > + > + /* > + * Attempt to migrate memory to device, which should fail because > + * hopefully some pages are backed by swap storage. > + */ > + ASSERT_TRUE(hmm_migrate_sys_to_dev(self->fd, buffer, npages)); Are you really sure that you want to assert on that? Because doing so guarantees a test failure if and when we every upgrade the kernel to be able to migrate swap-backed pages. And I seem to recall that this current inability to migrate swap-backed pages is considered a flaw to be fixed, right? > + > + ASSERT_FALSE(write_cgroup_param(cgroup, "memory.reclaim", 1UL<<30)); > + > + /* Check we still see the updated data after restoring from swap. */ > + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) > + ASSERT_EQ(ptr[i], i); > + > + hmm_buffer_free(buffer); > + destroy_cgroup(); > +} > + > /* > * Read anonymous memory multiple times. > */ thanks, -- John Hubbard NVIDIA