Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2779900rdd; Sat, 13 Jan 2024 01:24:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtLI+dks2hVQgaB+if0xwc2b3CtY/6EzSc7Ru474bkf2faa/JSca8YN2vxDxxEH2V8s3qM X-Received: by 2002:a05:620a:298a:b0:783:195e:5c2a with SMTP id r10-20020a05620a298a00b00783195e5c2amr2961422qkp.93.1705137858692; Sat, 13 Jan 2024 01:24:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705137858; cv=none; d=google.com; s=arc-20160816; b=VxdYbNZ2UybGlFW0ycEm38J+EUcvtuAWwAhJAEI/4h9cdS5XAk93v1SUtm1PcKG/eq 0neYDpIkCeiQ0CPPsoNH7uycuZuBrLZ3DPURm/j+imTy0sQr4j6nhTZvjUJBDiH4H2Lo 94cJspUh1uRmJVXpRz20pWWspG+cIXwZx4jY8Ub3A+Nq2pymjzz3tuJw+tpbCCxK4lFk ZVUsNL6DpqVad9eWmv6G2gQ1gv7PHt57uCfWz8X+DGQo1wg7BN/6A5wxLw9nhx1Sq/yd 9xAq0L5ZXqirhiz+gW0paPghAJTI3e/GbidHHBpiBjf9Xz+yqL+lxJrnZmsj8UNpKxUT lazg== ARC-Message-Signature: i=1; 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=mG8ngPgKidpc6DG7VcOonL9w+Hnp78zOGjk/tfdl9Tw=; fh=KtmuM4t+2D/0bgkLGSGV2OTdmeV3Sg+Pwv69Xxa5wIY=; b=09vqYWo0F+CjzMHFqr5h8oiTGBPDkL5wPegCCjD9YO22MRm+hVumPWvyDQR43QGR+5 YZWrrNOmseqrZqos3Vicj41f0E2Gik/JbwftPU48b3Y5hOBEZ54NTjd98XA7wliMrLBE 9JrAyuu9Ic2y6pw33CWENTQU5pPdbxUbfDmmDpEw9zIEMMmZCtyGMOEVznd1prP3HNQj lrfIXilq4yikhGb3i7DoTdtOxzx4RSYA99k4xoj7UCIqmbm66qLbuXjO1V6BL5MlPpq4 WEIAjPnrumFncZ5ZpZZ5hQuiN9OCkDfsdK1aFOBPLXWJKkzm19KENKbDjmHxIX6z0LOP Rg1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vn5YEivO; spf=pass (google.com: domain of linux-kernel+bounces-25235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s2-20020a05620a0bc200b007833a6f1f8dsi4686512qki.240.2024.01.13.01.24.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jan 2024 01:24:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vn5YEivO; spf=pass (google.com: domain of linux-kernel+bounces-25235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25235-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 70D241C21D9A for ; Sat, 13 Jan 2024 09:24:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CDB50A3F; Sat, 13 Jan 2024 09:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vn5YEivO" Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45]) (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 B1BB57E8 for ; Sat, 13 Jan 2024 09:24:10 +0000 (UTC) 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-ua1-f45.google.com with SMTP id a1e0cc1a2514c-7ce9defc4c2so917275241.0 for ; Sat, 13 Jan 2024 01:24:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705137849; x=1705742649; 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=mG8ngPgKidpc6DG7VcOonL9w+Hnp78zOGjk/tfdl9Tw=; b=vn5YEivOcF8tWeywC6GM7xeJ9UkzFwXVY3EBfbU6t+Jntvf83lg3G19hn1y+vDMgoZ c2EM8RshJsdMvlvFOFt9z28m5zeKGwxQR+uTUWNEU72bRdUpLLEpxb+7g95TkKo7rtfg C+OY1qvnhha8jhBz1HkZ7WCob4pkBCvfYaciC2OEsYhjvjXAYQxnR4u9MOi4lton4fYC o/V5dAbxb1WgrqW/9fSvdzeNDcf8bmHfPpqp0i/O29/VgoaZeYrzt8Tk1yimZz4p+v7Z BlbfgUZNZBRjkaMSgalfi3+yvvAMmDgGDqK3z2dO0Hy5BSl9uS154jilYuIY8GYlBv3F wo0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705137849; x=1705742649; 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=mG8ngPgKidpc6DG7VcOonL9w+Hnp78zOGjk/tfdl9Tw=; b=arzTqOzR/gsMXnr0lYsAeiaO+4z+TVzgMNDoy2YAu6dAx052QSgCJBYTYLmUIg0LgZ GEBRBu7SKsyvDzVTxYAXrVsR9bzrRSoGNFo/6ms6ycQLOdUHR19Y/O9j4/hzbc9hfoia YGqdncf3oN3MNGYpttLNaZ1asF4Kt3/JaIvohZbxptQMcO3Cso4EmH9QKhoLNNb6ljeO P/3CuENUNJnSL32cm9Hjtrdsxw+hyR6Q68RPsTBI5DNW0BJy+vTwQxTxEQ4RnatoaoZz d8zAmyrK9sE4sCJud1rxTKrorWCuFUFfRd5T9Y4ubXFKetKIjg32MIKm8NAF6e9qiXou htrw== X-Gm-Message-State: AOJu0YwDuhzoCt5mjfzD6ldqmQOhQ4TVTQ1RXagXAR2GaZlJp3hMiKE4 HOyr9U7uZDz/RtElWk1omMRFz8bGWSGAmb+vrMVyFrafjXMf X-Received: by 2002:a05:6122:4308:b0:4b6:f1e0:956 with SMTP id cp8-20020a056122430800b004b6f1e00956mr1346224vkb.17.1705137849491; Sat, 13 Jan 2024 01:24:09 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <87sf34lrn3.fsf@linux.intel.com> In-Reply-To: From: Marco Elver Date: Sat, 13 Jan 2024 10:23:31 +0100 Message-ID: Subject: Re: [PATCH v4 12/22] lib/stackdepot: use read/write lock To: Andi Kleen Cc: Andrey Konovalov , Oscar Salvador , andrey.konovalov@linux.dev, Andrew Morton , Alexander Potapenko , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" On Sat, 13 Jan 2024 at 10:19, Andi Kleen wrote: > > On Sat, Jan 13, 2024 at 10:12:21AM +0100, Marco Elver wrote: > > On Sat, 13 Jan 2024 at 02:24, Andi Kleen wrote: > > > > > > On Fri, Jan 12, 2024 at 11:15:05PM +0100, Marco Elver wrote: > > > > + /* > > > > + * Stack traces of size 0 are never saved, and we can simply use > > > > + * the size field as an indicator if this is a new unused stack > > > > + * record in the freelist. > > > > + */ > > > > + stack->size = 0; > > > > > > I would use WRITE_ONCE here too, at least for TSan. > > > > This is written with the pool_lock held. > > ...which doesn't help because the readers don't take it? This function is only refilling the freelist. Readers don't see it yet because it's in none of the hash table buckets. The freelist is only ever accessed under the lock. Once an entry is allocated from the freelist, its size is overwritten with something non-zero (since it then contains a stack trace). Those updates are released into the right hash table bucket with list_add_rcu() (which implies a release). Am I missing something else?