From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C77D262804 for ; Tue, 25 Feb 2025 10:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740477716; cv=none; b=lUhxOLCKLEy6XvocvWujhw+CFmEybA9KCuUJHR6L5g0cqTHrTxvurT01PJrqu+KI2bsrKzNIFWoO7mvSBL5m6DEblc8bvarEvGd1yzvcOpnQTanKX2No8x0/7XkZSM8C24GSFCxlqQVY9dPODTcNbfVGkbYINCK6YMrlHQpQwm8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740477716; c=relaxed/simple; bh=WbTYhd6foXSyOnfHVbKms0+sMhqGA+RO5PTab0PSDIY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TYMfbLcgwNdTVxnnl6iSFwethxv8FA+cjIJn0At3NV1QxFvoCLnNIBkAQPngoVuBO6bCMV6ms6AxlYnFzIj8I8DcdF6Beip8x8W2vfEGPOLqc1WXZ4BM9ADjsC469fr/9EOiKWz0D/GhFETNpDAwP/FGoSJXRqzXIxKYcid3Dkg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=I6dfwBdm; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I6dfwBdm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740477713; 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=/+h+fPj09zWYTw7qPd+IesJvhzV1Nb7N0plz81q+GsY=; b=I6dfwBdmruydgBDpO6ARgdGNR3vfNj4LuVfley2PFw7go2atMr+omOlNu4VdSHk832Ya4s xk3LQMoNnuIb5iQK6TFO+tiLL/qTedlJ6EJ6SkdBF7hFpNRgFN0zkvIGx5y2UyTTzbisku hBbN3W4LZ+R8D0omrdOc7Uy/MLuHgow= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-BmfnxDVmM2qT0Wmt7WSb6A-1; Tue, 25 Feb 2025 05:01:51 -0500 X-MC-Unique: BmfnxDVmM2qT0Wmt7WSb6A-1 X-Mimecast-MFC-AGG-ID: BmfnxDVmM2qT0Wmt7WSb6A_1740477710 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-38f27acb979so5037623f8f.0 for ; Tue, 25 Feb 2025 02:01:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740477710; x=1741082510; 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=/+h+fPj09zWYTw7qPd+IesJvhzV1Nb7N0plz81q+GsY=; b=l73MaFCIsxoJgyjuJN8miZWhL2XTo/rFq68BiZ1K6XXsR+DfJ2bj3gyz9zURpY9YDS MDtCYcEV+HRB6Qr9I+iv3311hgCU+lq9BBL4h/8hqNoNUBSShgQOBsFUD8a5FSg7rAFv Ryn1ypBqAduf8Sz+hYMzxx58+K/j7jC85eBxtSPLpckPrFENi2O2B4SwNsSD4TztZZua 5j+rGg5EmGu0/f4xYp3DaXeeBH30/l9K74z1TF7VvOFEVudGe+xaINHw9XRt6Ai+nklT TRpmVJo3neNyg3atTSSmEnTZMU/HmNufgpZE5Zymuy9dh1SIHF3oj+hSFSPd3JsMWqD0 T40A== X-Forwarded-Encrypted: i=1; AJvYcCUcSZqORyOHt19iNtC0z5loJPQ6rnESgvotZwrdAeJHy4nX1MAWrLBfHi0KGFGfs7jin5QVElIKfk+wbHk=@vger.kernel.org X-Gm-Message-State: AOJu0YwkINZDorShUUaCphs46+FjnDTVy/wEOz9F5jyPlpjci9aB112R HDW9QKt3srm28E84uUUR8qnJMJ6pfw6KeEYuO/atBSl05S+YmjW8KpEzFsTbEO4ReaMOxw4oVoI ToJCtNMmfTmxQM/cMeguNhISV8a2jlLBnUuks+LjPwhgiUH9XDaSQra6tpb2Z1g== X-Gm-Gg: ASbGncuKPse7PMS7jdbGJT0ePFdnI0iwNbqbd8nekH77JjXsZk9IMiHTxS2aOY+xxE7 xMu6NjEXrl9mCU7UQDv0ekDJYGVpdWQqVUcdGDVDp+l+nwSgB66FolRNAlVMLkuukNoAKbOc8G5 rCzXJJxgzQhe6QqqjT8vwhULdgIWvljrPM1JSfbrm7pJvMH/BHyDmxU5ihBr/KTlQ4Bt4zOCSyM dKFWeMzom2yDKXjNtFDJuU6rgAhcrH6E4v5tzc4PMiwzjFREHDiimYLTqQxO6iHz07oTTP0ixEa OZr9o+vLdYuQ49knb/BhMTZPPWVxUbmNcOSH1OG5fB/P X-Received: by 2002:a5d:5985:0:b0:38d:d3e2:db32 with SMTP id ffacd0b85a97d-38f70783f03mr9711754f8f.7.1740477709839; Tue, 25 Feb 2025 02:01:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCN1SYAAIz/pF5xUoJzar7+lMabbaLjjeF4ndao2dvfBcddNuVf6uQYJyuKutyCNt+md6VWA== X-Received: by 2002:a5d:5985:0:b0:38d:d3e2:db32 with SMTP id ffacd0b85a97d-38f70783f03mr9711727f8f.7.1740477709379; Tue, 25 Feb 2025 02:01:49 -0800 (PST) Received: from [192.168.3.141] (p5b0c6373.dip0.t-ipconnect.de. [91.12.99.115]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390cd866dc4sm1753169f8f.11.2025.02.25.02.01.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Feb 2025 02:01:48 -0800 (PST) Message-ID: <0449ff75-0a6b-4c1e-bf12-ff052aad5287@redhat.com> Date: Tue, 25 Feb 2025 11:01:47 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC 0/4] mm: KUnit tests for the page allocator To: Brendan Jackman , Brendan Higgins , David Gow , Rae Moar , Andrew Morton , Oscar Salvador Cc: Lorenzo Stoakes , Vlastimil Babka , Michal Hocko , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed References: <20250224-page-alloc-kunit-v1-0-d337bb440889@google.com> From: David Hildenbrand Content-Language: en-US Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK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1trDQmPx2iP5+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: <20250224-page-alloc-kunit-v1-0-d337bb440889@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 24.02.25 15:47, Brendan Jackman wrote: > The page allocator does a lot of stuff that is not visible to the user > in any deterministic way. But this stuff is still important and it would > be nice to test that behaviour. > > KUnit is a tool for unit-testing kernel-internal APIs. This is an > attempt to adopt it the page allocator. > > I have been hacking on this as a way to try and test the code I'm > writing for my ASI page_alloc integration proposal [0]. It's been > extremely useful to be able to "just call it and see what it does". So I > wanna gather some feedback on whether this basic idea is of interest > before I invest too much more time in it. > > You can run these tests like this: > > tools/testing/kunit/kunit.py run \ > --arch=x86_64 --kernel_args="movablecore=2G" \ > --qemu_args="-m 4G" --kunitconfig mm/.kunitconfig > > Unit-testing code that has mutable global variables can be a pain. > Unit-testing code with mutable global variables _that can change > concurrently with the tests_ is basically impossible. So, we need some > way to isolate an "instance" of the allocator that doesn't refer to any > such concurrently-mutated state. > > Luckily, the allocator only has one really important global variable: > node_data. So, the approach here is to carve out a subset of that > variable which is as isolated as possible from the rest of rthe system, > which can be used for deterministic testing. This is achieved by crating > a fake "isolated" node at boot, and plugging in memory at test init > time. > > This is an RFC and not a PATCH because: > > 1. I have not taken much care to ensure the isolation is complete. > There are probably sources of flakiness and nondeterminism in here. > > 2. I suspect the the basic idea might be over-complicated: do we really > need memory hotplug here? Do we even need the instance of the > allocator we're testing to actual memory behind the pages it's > allocating, or could we just hallucinate a new region of vmemmap > without any of that awkwardness? > > One significant downside of relying on memory hotplug is that the > test won't run if we can't hotplug anything out. That means you have > to fiddle with the platform to even run the tests - see the > --kernel_args and --qemu_args I had to add to my kunit.py command > above. > > So yeah, other suggestions welcome. > > 2b. I'm not very confident I'm using the hotplug API properly. Me neither ;) Dynamically adding memory to that "fake" node is certainly interesting, but which guarantees do we have that some other features (page migration, memory offlining, page reporting ...) don't interact in weird ways with this "fake" node? Adding special-casing all over the place for that feels wrong. I assume this is point 1. you note above. So I don't quite love the idea on first sight ... but I haven't grasped all details of the full picture yet I'm afraid. -- Cheers, David / dhildenb