Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp767256rdb; Thu, 8 Feb 2024 23:46:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMd927bsbGxSpF6NqvkgYmYhswUoij6mEIq9ltakvnFLN85hp1FSDuASQBTxFebs+b5Xze X-Received: by 2002:a05:6a21:e85:b0:19c:a2ec:64f with SMTP id ma5-20020a056a210e8500b0019ca2ec064fmr1200535pzb.2.1707464766087; Thu, 08 Feb 2024 23:46:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707464766; cv=pass; d=google.com; s=arc-20160816; b=eRk1x3Dz1llzaqiW9Vq0Jb08DJKapKkPBpBwZ3XYYxTZOAF4XKr3RyLR9/6tb+J5TN 83My7Ygs4dkPB69gRjS6O+NcX3Udt5yHbbguNqTub9lNk1qq3Vpawbs5R0FPbHMn2Cen dFP1Qd+MbTEQIPeJtapSPdrY84okYbzt3I8+NOF67YeKHHMEvUktRmcnbcFck8saoedt Ocb0HcljN+eQX6u7AKUEpKzcTMn5Cg4PkBhhioH7je8RGnJLZvQACMMFnbQKK0OeYgUZ GEISilr729DyOy1S5sPxSyZI5vzf/wm9nhGR14ofADR+NyeeYQ57IGeKDm6pyHO8HIja ZvVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=fLYosVJBxJJ3XJbpjWGEbQR6KVWU5Ojl+eaZgpRroOc=; fh=dzDOj9QpMkmJnKJ9FgfhH/ImB6G5cq6YsVHc4enb+eY=; b=TZjHw1iOizIYEWBTUgxg+rvGunJm6zDk7ppX6RT41sOwHjJh7gMA3IMEAMArGr9Crj ZJhQqME5U5vYKgO9ZMH9xOS0r0figyqkj74DKHOiUOopjhJuIt8kUiP26I4ob+vvOuRF w7xZ5ts6+6LtL1VQuMpn9o3bdfjGWuHeUVnMONPYpfE+6DeHX4nZGDVDx9osXi99+iOz dtv5oc/AktclE8kg/Qd8+pKmquYz/U9OrL443DyzAwccdo5NPbkHgcCxWrywVIDUV/T5 eOX/aN790o5laNGluwAiZMvCuj8BUajVzRqelUwq4qGY6ec+7chlPgx4ELVtO0eq1jmR 8RCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="uSpu/J+7"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-59084-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59084-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCXCAdmGHAxoYiDvcyhcG+vNnPpd08oNuDC4KqGm0GavlQtrepwuh7umjpZDWCRmS0QBrz/zmAbl85JgdkEI1sFCSL84vJavYS6/GNn2sQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d5-20020a170902654500b001d9eb74fce3si1202913pln.434.2024.02.08.23.46.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 23:46:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59084-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="uSpu/J+7"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-59084-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59084-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BA0232840C9 for ; Fri, 9 Feb 2024 07:46:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AE9D65BAE; Fri, 9 Feb 2024 07:46:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uSpu/J+7" Received: from mail-vk1-f182.google.com (mail-vk1-f182.google.com [209.85.221.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85155657DA for ; Fri, 9 Feb 2024 07:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707464761; cv=none; b=FCJblMPxgsHeM2dvKoTKN0zGrB98yupMZDEEbvfedNyR+gy1S2MsLfRIgl3qXuClwqoWKIXFJz4hlffCNtnGrduazgVl1x3rUknlSfcky2uN8wW9pm61heHTIKPrC7xdgcIAFqt0qlHT+NL8wy/tZ+OInzyKq1jqx7LnRxM/ZBc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707464761; c=relaxed/simple; bh=eTIwtSQ2nu2DzmbaloUx2RHR94ej1My9IhiHqA1fgvM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ukCjmK4EwxBw+M6PMqHNqvCQCHU+gE3Z/7YjEVOpwZ3NayffBwSjApyRZsvEbIacPAhsj4+stGCFe8P6JfbQsFRY5FzNUpN7y1kxneonsMvc9GTPYXVsZgR1S17Ks/DTZFMgkKfPvij6rbUPg2gAMxzdr4fROSq3HkjF4aTGAJ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uSpu/J+7; arc=none smtp.client-ip=209.85.221.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-vk1-f182.google.com with SMTP id 71dfb90a1353d-4affeacaff9so183436e0c.3 for ; Thu, 08 Feb 2024 23:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707464758; x=1708069558; darn=vger.kernel.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=fLYosVJBxJJ3XJbpjWGEbQR6KVWU5Ojl+eaZgpRroOc=; b=uSpu/J+7JYrygB5Ct4+U5D7jHWBjGnisYyQlsnBh1b2fvLkFdghoUbizA300y+FSfR LHvqFwen0jHN+Pi25lRJo60J3UR0BL4FzFfk+Ei80mkP5nPvFA2Rj9aMvkqYw0MqVIfP gHjemRlZMeztlel+72FtNcBrJpyFR0lJsxlPGNjgpOHZ057AWVJPA6zqih3aZ0/+inX+ A0P59rijQMvqYsuNRbfMy9kQ5D8moFrrROULrsT5DziNPxFb16cp3UW7RHAMYbXhKcvZ uv0Qr2g+2vHZDvCDUzKPBuqadqMlxy3/PRLCu5mXGyVIZzz4KWNpKupelr5ZJmRoPPkd Vl5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707464758; x=1708069558; 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=fLYosVJBxJJ3XJbpjWGEbQR6KVWU5Ojl+eaZgpRroOc=; b=eW9Ll/I6NUay+SLhfBi8+oTlSOhrT4e/GNxOca48//8uvGChfBMx9UPkeMY4luh9Tr kSHuaVulN49sb2RVlsW3mQ+2LwiydFn6CnCk9/woyY3yK0AgyVt1bm/MIvGEIaHtGvkB +Cdm6XHpH4XDUG6szN9gbeND4Jeswunmy/qIu2fXeyjRTeqEBz0sJa45QsO0Qfgz5z+I jIe2v9cjffwL/P5TNCr/cpTEkDFwTybawLXlIbL4BQH8R3hFXnqvYHVfTfdQDHA1F2/C SkSB6H/bBdC9SknsXbC7btityKNST+TFQuSITP04eK7T9h1hs1HQwg1cI/SXKl4qkwzJ JT/g== X-Gm-Message-State: AOJu0YwVNKwkTh9ghv/N25S3jWJqK56Kb/TakcmBFEtmQ54j4yCpc6Xl Ub5l/XFOEmoOmw05Q59Ik978ot763TdBcqYtR8i7kl9zPD6dYZMfhOybPFUud4Nq1+zoudXyY11 gs9y7oHv28rmmuh0tNQwq9zUQ6tWZsBlNcNpNzUge59/EdVe4Cw== X-Received: by 2002:a1f:ea01:0:b0:4c0:3c09:6f34 with SMTP id i1-20020a1fea01000000b004c03c096f34mr939892vkh.2.1707464758253; Thu, 08 Feb 2024 23:45:58 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240208234539.19113-1-osalvador@suse.de> <20240208234539.19113-2-osalvador@suse.de> In-Reply-To: <20240208234539.19113-2-osalvador@suse.de> From: Marco Elver Date: Fri, 9 Feb 2024 08:45:21 +0100 Message-ID: Subject: Re: [PATCH v7 1/4] lib/stackdepot: Move stack_record struct definition into the header To: Oscar Salvador Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Andrey Konovalov , Alexander Potapenko Content-Type: text/plain; charset="UTF-8" On Fri, 9 Feb 2024 at 00:45, Oscar Salvador wrote: > > In order to move the heavy lifting into page_owner code, this one > needs to have access to the stack_record structure, which right now > sits in lib/stackdepot.c. > Move it to the stackdepot.h header so page_owner can access > stack_record's struct fields. > > Signed-off-by: Oscar Salvador > --- > include/linux/stackdepot.h | 44 ++++++++++++++++++++++++++++++++++++++ > lib/stackdepot.c | 43 ------------------------------------- > 2 files changed, 44 insertions(+), 43 deletions(-) > > diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h > index adcbb8f23600..d0dcf4aebfb4 100644 > --- a/include/linux/stackdepot.h > +++ b/include/linux/stackdepot.h > @@ -30,6 +30,50 @@ typedef u32 depot_stack_handle_t; > */ > #define STACK_DEPOT_EXTRA_BITS 5 > > +#define DEPOT_HANDLE_BITS (sizeof(depot_stack_handle_t) * 8) > + > +#define DEPOT_POOL_ORDER 2 /* Pool size order, 4 pages */ > +#define DEPOT_POOL_SIZE (1LL << (PAGE_SHIFT + DEPOT_POOL_ORDER)) > +#define DEPOT_STACK_ALIGN 4 > +#define DEPOT_OFFSET_BITS (DEPOT_POOL_ORDER + PAGE_SHIFT - DEPOT_STACK_ALIGN) > +#define DEPOT_POOL_INDEX_BITS (DEPOT_HANDLE_BITS - DEPOT_OFFSET_BITS - \ > + STACK_DEPOT_EXTRA_BITS) > + > +/* Compact structure that stores a reference to a stack. */ > +union handle_parts { > + depot_stack_handle_t handle; > + struct { > + u32 pool_index : DEPOT_POOL_INDEX_BITS; > + u32 offset : DEPOT_OFFSET_BITS; > + u32 extra : STACK_DEPOT_EXTRA_BITS; > + }; > +}; > + > +struct stack_record { > + struct list_head hash_list; /* Links in the hash table */ > + u32 hash; /* Hash in hash table */ > + u32 size; /* Number of stored frames */ > + union handle_parts handle; /* Constant after initialization */ > + refcount_t count; > + union { > + unsigned long entries[CONFIG_STACKDEPOT_MAX_FRAMES]; /* Frames */ > + struct { > + /* > + * An important invariant of the implementation is to > + * only place a stack record onto the freelist iff its > + * refcount is zero. Because stack records with a zero > + * refcount are never considered as valid, it is safe to > + * union @entries and freelist management state below. > + * Conversely, as soon as an entry is off the freelist > + * and its refcount becomes non-zero, the below must not > + * be accessed until being placed back on the freelist. > + */ > + struct list_head free_list; /* Links in the freelist */ > + unsigned long rcu_state; /* RCU cookie */ > + }; > + }; > +}; > + > typedef u32 depot_flags_t; > > /* > diff --git a/lib/stackdepot.c b/lib/stackdepot.c > index 5caa1f566553..16c8a1bf0008 100644 > --- a/lib/stackdepot.c > +++ b/lib/stackdepot.c > @@ -35,14 +35,6 @@ > #include > #include > > -#define DEPOT_HANDLE_BITS (sizeof(depot_stack_handle_t) * 8) > - > -#define DEPOT_POOL_ORDER 2 /* Pool size order, 4 pages */ > -#define DEPOT_POOL_SIZE (1LL << (PAGE_SHIFT + DEPOT_POOL_ORDER)) > -#define DEPOT_STACK_ALIGN 4 > -#define DEPOT_OFFSET_BITS (DEPOT_POOL_ORDER + PAGE_SHIFT - DEPOT_STACK_ALIGN) > -#define DEPOT_POOL_INDEX_BITS (DEPOT_HANDLE_BITS - DEPOT_OFFSET_BITS - \ > - STACK_DEPOT_EXTRA_BITS) > #if IS_ENABLED(CONFIG_KMSAN) && CONFIG_STACKDEPOT_MAX_FRAMES >= 32 > /* > * KMSAN is frequently used in fuzzing scenarios and thus saves a lot of stack ^^ This hunk no longer exists, try to rebase against the version in -next. Other than that, this looks fine.