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 C8288C021BB for ; Tue, 25 Feb 2025 11:15:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 42E286B007B; Tue, 25 Feb 2025 06:15:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B6F16B0082; Tue, 25 Feb 2025 06:15:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 257416B0085; Tue, 25 Feb 2025 06:15:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0719A6B007B for ; Tue, 25 Feb 2025 06:15:11 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9F22A81223 for ; Tue, 25 Feb 2025 11:15:10 +0000 (UTC) X-FDA: 83158210380.14.46D9B27 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by imf16.hostedemail.com (Postfix) with ESMTP id C22D8180002 for ; Tue, 25 Feb 2025 11:15:08 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Nq73rxGV; spf=pass (imf16.hostedemail.com: domain of jackmanb@google.com designates 209.85.160.170 as permitted sender) smtp.mailfrom=jackmanb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740482108; 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=Xc5yW/4rgg5KqhOxif21KGnv89ZFaMc+1AokhRRA/h0=; b=2+NNeDg8uskn8KFWJm6AJS8csXn+Szoq+9RvKVgRTa4gJv0Y8km2mG2tU+wypPyRvNwxxb BCFQwvdLManH+BWA06+v5JiW1kgvYm6qwzdo2T4CYWLyMQ626Q2Q2tk0YPL56ASHYDdC6+ p+kPDL05ihvdxBJWjAYzTMyYOzIU6V4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Nq73rxGV; spf=pass (imf16.hostedemail.com: domain of jackmanb@google.com designates 209.85.160.170 as permitted sender) smtp.mailfrom=jackmanb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740482108; a=rsa-sha256; cv=none; b=ZO5EZ3Va2YpvcJfj94pMTZ5nNZDhtDPCJasDrXO45hJgZ5quhTiWkGgcbnpSKbfQrxPw96 1GBMBLFKkOexfqt8fbfUbZ1ua4ibBSNseKrFbD/zYSvbAv45HVfDHov09bCecGKPvVy0xC fkdk0PLQgiceP8Evkt627trgOx6UdOM= Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-471f1dd5b80so170891cf.1 for ; Tue, 25 Feb 2025 03:15:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740482108; x=1741086908; darn=kvack.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Xc5yW/4rgg5KqhOxif21KGnv89ZFaMc+1AokhRRA/h0=; b=Nq73rxGV5OkU6SSth5AfhXxft2PJTumdRAQhCuSPyylc9DXRLHfqjsqepZPBLbx76q 0gmsNJJ3biHWqpLs8BPga2f0bLe+hlNbYjNNAmp1FJcS3SBvXy7l2H6UKTBu6/23D0c6 vKX7FQs4zCTqNkZDn9EfThtR8yWLkFUZOWgi76bJo3/4DxT0Vf23Hn6NmENeBuH9Fbc2 fgc+Ec5YSNM0h3nhspyM7Xuv248VzI2gZmJlfgrVH1szJwSX8jjw+D6b7T7kIJPEgub/ leG5+9d+U8TkinILsegQNoNis9w8+Io5b1b7/bS+3XGYNpMp3q1Sy76daBSS8fbDDwl+ c9Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740482108; x=1741086908; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Xc5yW/4rgg5KqhOxif21KGnv89ZFaMc+1AokhRRA/h0=; b=Vk7zleZBuXkKFnOwNp98MEHL2MIzYTa3coLnM+46tfJOt76q1bXguglx3YvVGBC0ce rqvDW4m4k5RfQxxEk00GIoaXVM3k/zXnXLE/fuSS735OxlKhpCg78wcarJnSAORhOQwg KHkMpepdOveodqtzY5EzYOEQSJ1QL3PXKyY7l5y+wS7yt1UXEHz1bRd5RTCH3PcrOPPC ktiV8Zjrfxvh8bveH80uZibTXPid5ZETuPv1++wC/GPgNlnIwjmX5MmN87TyRuCf9JVn no+Hi8fAY8pH48PWuYoR3b6CvfJa9Lcf0TcquLms/QiOkicY7XPy7IoTouJEhDIJfbNT mIhw== X-Forwarded-Encrypted: i=1; AJvYcCWGC9/F8AOOgqqm1nNTDfHu33H7dWvFcCFZI7qFCf2yLDywswTrcAuJl0w/vhC8Dt2TJ1GGb5gLmA==@kvack.org X-Gm-Message-State: AOJu0Yx4AL1uSGaX4M9iNeaZIdJBPzKwS1oVqY/doNjYtM5bOFhpxr2I oKRgL3H8hD5vzWP8eUlPyBp9yWS1+WYLRsPCDnDX5Js99ABq2NvDBKgc1kgwpsdgW5Hvfqnv6dT 3ndV2q/OmbxcTmqqBfltM1KG6cpx7INi018// X-Gm-Gg: ASbGncvco1AekeN0F9PVmZKE7pKGs/TaDds8ospjysbsWZ31HXr1t6I80cdRgm0cAUR sfMi57ikxQZvmgtUk8J0uWzwo3Vk1bDs28ED9K1quR+pKzXycJ8gHrwm6jAWmmubjjHZ7dWGE5N kPhsU3f4u7M9aL9vfeqIJF3j1nfpn5LPwxqJQtSA== X-Google-Smtp-Source: AGHT+IF293xeVyj4/wAp5kXWhSXHvlqZ+hGOq5jwSu7o+tmHkKY22JHmZitJTtCcPuuUlKFOv+HkABOvq5lh90WmCTc= X-Received: by 2002:ac8:7c48:0:b0:471:fb3a:5bfb with SMTP id d75a77b69052e-47376e5de43mr4324371cf.1.1740482107770; Tue, 25 Feb 2025 03:15:07 -0800 (PST) MIME-Version: 1.0 References: <20250224-page-alloc-kunit-v1-0-d337bb440889@google.com> <20250224-page-alloc-kunit-v1-4-d337bb440889@google.com> In-Reply-To: From: Brendan Jackman Date: Tue, 25 Feb 2025 12:14:56 +0100 X-Gm-Features: AQ5f1Jr2V__EQDgXK12d3od3hg4EIBPZN4EogawQjt_yGI4eSiDAQDJGxAHmIjU Message-ID: Subject: Re: [PATCH RFC 4/4] mm/page_alloc_test: Add smoke-test for page allocation To: Yosry Ahmed Cc: Brendan Higgins , David Gow , Rae Moar , Andrew Morton , David Hildenbrand , Oscar Salvador , Lorenzo Stoakes , Vlastimil Babka , Michal Hocko , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Stat-Signature: mheirswcmkm6kby8f9chd4zkibryk75p X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C22D8180002 X-HE-Tag: 1740482108-373135 X-HE-Meta: U2FsdGVkX18SUCvBOJ7p/cDp3kCfTDBdq0ASjm0QbDif36X1f7T5Eg1z7ZSiVg8xYlCcbbRbs0y4TkIEtJMj1nL6HkfKOlh7MC3ZNBKpLD9PgVzFEOY54/UNmMXxgOJ0eG0yhK4FCkyjuQURCgpUSCpnuj+EMqT8F6+FlW01P65v/6eN2b4zUm4pfElOOAPlY0BJ2aYIrtB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owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, 24 Feb 2025 at 19:26, Yosry Ahmed wrote: > > +static void action_nodemask_free(void *ctx) > > +{ > > + NODEMASK_FREE(ctx); > > +} > > + > > +/* > > + * Call __alloc_pages_noprof with a nodemask containing only the nid. > > + * > > + * Never returns NULL. > > + */ > > +static inline struct page *alloc_pages_force_nid(struct kunit *test, > > + gfp_t gfp, int order, int nid) > > +{ > > + NODEMASK_ALLOC(nodemask_t, nodemask, GFP_KERNEL); > > For the sake of the test can't we just put the nodemask on the stack? Hm, I think whether or not it's test code is irrelevant to whether we can put it on the stack. Presumably the nodemask code is written as it is because nodemasks can be massive, so we can overflow the stack here just as easily and confusingly as anywhere else. (I think we're not in a very deep stack here right now but KUnit could easily change that). FWIW I think when using the mm/.kunitconfig provided in this series it does actually go on the stack. > > + struct page *page; > > + > > + KUNIT_ASSERT_NOT_NULL(test, nodemask); > > + kunit_add_action(test, action_nodemask_free, &nodemask); > > Why aren't we just freeing the nodemask after using it, before we make > any assertions? I guess that's just a philosophical question, I usually default to writing KUnit code such that you can throw an assertion in ~anywhere and things just work. But, I'm not passionate about it, I would also be fine with freeing it directly (it would certainly save quite a few lines of code). > > +/* Generate test cases as the cross product of orders and alloc_fresh_gfps. */ > > +static const void *alloc_fresh_gen_params(const void *prev, char *desc) > > +{ > > + /* Buffer to avoid allocations. */ > > + static struct alloc_fresh_test_case tc; > > + > > + if (!prev) { > > + /* First call */ > > + tc.order = 0; > > + tc.gfp_idx = 0; > > + return &tc; > > + } > > We need to set 'tc' here to whatever 'prev' is pointing at, right? prev always points at tc (or is NULL). Sounds like it needs a comment to that effect! (Note tc is static). Ack to everything else, thanks for the review!