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 5EE93C83F11 for ; Mon, 28 Aug 2023 18:36:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A6A9228001E; Mon, 28 Aug 2023 14:36:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1AB68E0029; Mon, 28 Aug 2023 14:36:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E38928001E; Mon, 28 Aug 2023 14:36:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7BBB38E0029 for ; Mon, 28 Aug 2023 14:36:44 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 50D751A0370 for ; Mon, 28 Aug 2023 18:36:44 +0000 (UTC) X-FDA: 81174369528.17.1F4BEE8 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by imf11.hostedemail.com (Postfix) with ESMTP id 896C440009 for ; Mon, 28 Aug 2023 18:36:41 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=tl50VSvv; dmarc=none; spf=pass (imf11.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.166.174 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693247801; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=X9Wrti7ruRDIQ0mrefulR5Bcs52gq1wDF9eL/uOAQEA=; b=Cg3c4/KjrswnmjDvG3+zRjtIT/QhGoGi9oCIRSs8uE/KkllZXhpmnwmBenYDhiYeC/re85 s+01/ekarALbVa13bMcymyhOG+nJccUE5SQljH1hpjxJEqwEiqR+twZlnM/qdhDgb92VXB Vp4fEEDN3kBxQkkspSDI5g0sMf+Az8M= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=tl50VSvv; dmarc=none; spf=pass (imf11.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.166.174 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693247801; a=rsa-sha256; cv=none; b=cxfuIN5r2LEX4Iha5CocmfpOuvMOTVcju0Y2dXZfd09jfEC3PqyBPbvUXFbCdhAwpZeeBT PjhYlfe7iub7N+jOrlpIndtMnbqMXGe5IhQGjhvzyycZ32zHTGL3QQ13lTfc4FHbmxbAVZ 84NUIzSPSTyCRxVagoU8QRNDIgruyRA= Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-34ccc0fca24so12923155ab.0 for ; Mon, 28 Aug 2023 11:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1693247801; x=1693852601; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=X9Wrti7ruRDIQ0mrefulR5Bcs52gq1wDF9eL/uOAQEA=; b=tl50VSvvgUvsBEbTZibn5u/+m7f6Tpq+NuNMY++rln1mIQXSnHT3Bbh/8YNDZ7adhR tr1D9FfOhLMF3vAXyxYbYfZL04iva7oDpJxa3KH/O5iWC14avrrYL2jyerbWKuV+40GX WwTM2Y0HNMZLjkC4YB1XnbvP/AHVr6nspTcRI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693247801; x=1693852601; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X9Wrti7ruRDIQ0mrefulR5Bcs52gq1wDF9eL/uOAQEA=; b=V0uxT08Gb7bAAIRY0G0KqjOWI6oCEswWWUyWHxxamNcdbGm+dK8jGQibTThTmlB1gw xqv5BgPArTySPvOnZHPx2tYYHQ8I3yC1SkXjldXVc8UB8mxHly1g6857WotLLdThlduH 3vpncn1vqNCGMToTnm95GhmdQGR8jppnlxsk7Q27mYO6mnzFp32WwEX3AAJ8tY+/unxa WtEhOwGSYMoeQNq4CDPJNlplAtvADPAvhyM0ILsbFbI45II1BbBIt/S6GuG2eOHMoH4k yzBQc0TrKac/4v+Y+7lOVGXsqtQ298+mSulP+oSL50HtEi11SjnKDImSB0syGUMO8gjy JAZQ== X-Gm-Message-State: AOJu0Yzgiupaic08sJyQAe+xGcRf9MARYhyHCuLIQDxWH6M42gp70CXs nW9cy26k2D7o4V+JZuIisXtKpg== X-Google-Smtp-Source: AGHT+IGOyfeSMdefU0zTM7+SmFnidblDIgXQ53RaTHOyBx8hogxbNx7EUOVZ+UUxiq/GAW3pMs0AQw== X-Received: by 2002:a05:6e02:1646:b0:349:9745:89f with SMTP id v6-20020a056e02164600b003499745089fmr23108019ilu.17.1693247800771; Mon, 28 Aug 2023 11:36:40 -0700 (PDT) Received: from localhost (156.190.123.34.bc.googleusercontent.com. [34.123.190.156]) by smtp.gmail.com with ESMTPSA id o15-20020a056e02068f00b0034bae80711dsm2587715ils.82.2023.08.28.11.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 11:36:40 -0700 (PDT) Date: Mon, 28 Aug 2023 18:36:39 +0000 From: Joel Fernandes To: Lorenzo Stoakes Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, Shuah Khan , Vlastimil Babka , Michal Hocko , Linus Torvalds , Kirill A Shutemov , "Liam R. Howlett" , "Paul E. McKenney" , Suren Baghdasaryan , Kalesh Singh , Lokesh Gidra Subject: Re: [PATCH v5 5/7] selftests: mm: Add a test for remapping to area immediately after existing mapping Message-ID: <20230828183639.GB1621761@google.com> References: <20230822015501.791637-1-joel@joelfernandes.org> <20230822015501.791637-6-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Stat-Signature: 6dr98uknjwequyhmxqfkmz4ndquh5sqq X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 896C440009 X-HE-Tag: 1693247801-490235 X-HE-Meta: U2FsdGVkX1+tuCjBHGf2s440IyIRG3knqqeLTaqui+wHxgD4VLaO6sJmwNFqkLEhKjxuqdMcwcVDkafNDOl35o/qtUkutJ/SGt966/9SC/i3Wvmol/qNECUkGPFBm1Ie1KeMR+elJlLIKiBveX3FSKab0lwOWw8YQGDeYm+Tldcilm4Dem1gPQnsF/cPC/CcYBLreupu0MT4IsB8EtPxB0xUsgc9nUM7qek2EhDSeKiVtSQpNpNTdYNBpLrmGV54e4FYzV9Tv+vO2NhuKDN0INsXfzCk5zkooxHdE3YhuzX/fALRgqlNZ7iiIS4zyz6sDvJlWdMmp/tMC0/zoa7N92FYby1opnNSdFaqcTbT2smldx7i9vdWJUVlD9rttPBdyZRFxcPOk5Wpo5aH8oW371ErIRgh8VJdMg6WqrYqIaLK1PLNVxos4OUSQcyTkdDNt8JMeH8V624moXRpZCsMq29DlHxtTlG6hHQcL02frBQQ+r6KkWXQhWRAO9azI/WdWEVaDecAfV4Yu6mf8aElCdfxAH8bYY4Ws/u418gF0G2HEtgRbBJuXn4iIVFkSTXqlCZXMcks8/Kn/EfWzBusxSwp/YZBTIcdNiSiu/adpKmMg3AU56eD7ntCa82r4lwAWmzKdK49+ACU4xKg858mODlHPIXA9o1r+IvQ46NSWgeQc7X8eR3pR90D89nxsijbjwZhenxOjlFja4dtnSkYhYLfrJxN/OB6E53n7R3kOmW1qO9HOzAUYUpS20txiC6WYMx3eozz6w694IuTKr1LPb2PwtD+vkQYFTdfda7fskSS4p3i5b215smQGyZs48zOk+3dbqu3xj4xX0D3TsVB+BooOXTzhHpz3tjHFhmYh8q8X+I/Pj5MIoAzjyoq4cl1UuM4iKL5VwRMHBIpGhSyO+x9SmiyF4JJiCmtMRZQwcsJdNPpeyGprIFTGmkDapsGtWoa7igIL+xEvGiRVCY Z81QRyRQ Fu0Y4Kj9lDPqF9wSZUack05ZPwMYYbJ1M54oYyX9ObZSLYZl2jLvEwUGoX4G7Loy/bXfPoyAp+6slOSjxs+HLV+rsCl2UWBo8c7K+LzHrO0EItcWuXqE/hBSHMWx1bPOyqeoFHXn+I8UQT8YBXMmURQu5eNZ5QgRqIBmJczdmE3xdvkh+qJtnbefylH6SZu+/x9SOfzwstsvnCxT4eprHwj7gLFSy907QbEt1kQkjG3p8z+kWU6NQar2Y0Dc7iIi5yfh4s71ZpRZMKHpmxqw8P+Mua7bwZ3ptZppv+4eT6SWTSx9jjlcmseZa9o0cb3pMCxZbXZ0dWnKRrIFMlrfTWIwIJlo93Mzbtglh4KgtHB1+MWABGw13Fn+WNeVm2YfP2uqppq9xXQ7h7Tsn1xkcKxGcAY7PyTjqCIMj7FjY9E2PZEBe1Rath0IPOb/FpYZoWW1q X-Bogosity: Ham, tests=bogofilter, spamicity=0.000119, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Aug 27, 2023 at 10:42:44AM +0100, Lorenzo Stoakes wrote: > On Tue, Aug 22, 2023 at 01:54:58AM +0000, Joel Fernandes (Google) wrote: > > This patch adds support for verifying that we correctly handle the > > situation where something is already mapped before the destination of the remap. > > > > Any realignment of destination address and PMD-copy will destroy that > > existing mapping. In such cases, we need to avoid doing the optimization. > > > > To test this, we map an area called the preamble before the remap > > region. Then we verify after the mremap operation that this region did not get > > corrupted. > > > > Putting some prints in the kernel, I verified that we optimize > > correctly in different situations: > > > > Optimize when there is alignment and no previous mapping (this is tested > > by previous patch). > > > > can_align_down(old_vma->vm_start=2900000, old_addr=2900000, mask=-2097152): 0 > > can_align_down(new_vma->vm_start=2f00000, new_addr=2f00000, mask=-2097152): 0 > > === Starting move_page_tables === > > Doing PUD move for 2800000 -> 2e00000 of extent=200000 <-- Optimization > > Doing PUD move for 2a00000 -> 3000000 of extent=200000 > > Doing PUD move for 2c00000 -> 3200000 of extent=200000 > > > > > > Don't optimize when there is alignment but there is previous mapping > > (this is tested by this patch). > > Notice that can_align_down() returns 1 for the destination mapping > > as we detected there is something there. > > > > can_align_down(old_vma->vm_start=2900000, old_addr=2900000, mask=-2097152): 0 > > can_align_down(new_vma->vm_start=5700000, new_addr=5700000, mask=-2097152): 1 > > === Starting move_page_tables === > > Doing move_ptes for 2900000 -> 5700000 of extent=100000 <-- Unoptimized > > Doing PUD move for 2a00000 -> 5800000 of extent=200000 > > Doing PUD move for 2c00000 -> 5a00000 of extent=200000 > > > > > > Have you additionally tested this by changing the code to be intentionally > broken then running the test and observing it fail? Yes I did! Because while developing the patch, it was broken many times and the test failed during those times. ;-) > Looks good to me, > Reviewed-by: Lorenzo Stoakes Thanks! - Joel