Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2781733rdd; Sat, 13 Jan 2024 01:31:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwcxJF3wxzEy5TLGTwRs1QT/BjghISKG7m6vWCEtb7azuR/cofuWDMeu53S4NENXllz3Tq X-Received: by 2002:a17:907:268b:b0:a2b:1a80:7b8f with SMTP id bn11-20020a170907268b00b00a2b1a807b8fmr715296ejc.99.1705138269120; Sat, 13 Jan 2024 01:31:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705138269; cv=none; d=google.com; s=arc-20160816; b=XxcbuigPZvRWLtb9N2XAgYhMx8P5moBsY7XiKeXukOVvaNqVRP1hTdv48RaxFynJKY jiPdhliDj1ujqNY8uzY4Y7YvDlwWoCK5Qj1M0EPoTp8XSK2LdgqSEWBRQLwagy1WV/mV MPUmgrujFx7v6r1A75TIybEAaPQ6JelalYDvkFi6NjgAmV7Ryutj2rmkWCrH7MzFP6Hy yC/xNkmt+J9x765IJHg/olvFb8DEU7DF9Vyb7GkV3sJCHclQRcxQL6q4JRn3wjq7Z8o0 tVhsHHKcRNmgrNMyzD9HgUVNVAyhxO9zK3L/z59qe+OwE5Sz5BTNwo5sd2ySVrykjyTC Jzbg== 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=bs8F5F/gFkaaibZRS33VN3FkQujN/mSOo0oKKTFy/VY=; fh=KtmuM4t+2D/0bgkLGSGV2OTdmeV3Sg+Pwv69Xxa5wIY=; b=0GXx5wjaAhYUTTLla/zo8lIfFyh1vAaOqu70/Saw7dQbyJZ9gv0ank5WFwmxzaMCWF 1CedoVY15SOXtt6Gsb4wAJHa9DAB8RUKVAKKrn59xH4Rl8xYKaTldgEvhlh6wcDc+lp9 XbfgJVpiDfL9T8sV+eGPa25BvQ3kGPXMY/ib+ZCKc+c2ERMF1es/XLljmSmJAltlvkej wx2Ay5ysQKtgT4cWnSoietxn80qHMIUB94DNtQ9IETfM9g3j7P9+OWiimXxgduC6j1dd 53KSdQ6coZg341IqrbX3hwY29LBtqxbaRhF9rkzcvZRn+T8jaTrAXYyu+QcbHNPs72TI GpAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kKBmfDYG; spf=pass (google.com: domain of linux-kernel+bounces-25236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i15-20020a170906264f00b00a28da61a6fbsi2173176ejc.696.2024.01.13.01.31.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jan 2024 01:31:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kKBmfDYG; spf=pass (google.com: domain of linux-kernel+bounces-25236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25236-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AA48B1F21146 for ; Sat, 13 Jan 2024 09:31:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3B7E468C; Sat, 13 Jan 2024 09:31:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kKBmfDYG" Received: from mail-vk1-f174.google.com (mail-vk1-f174.google.com [209.85.221.174]) (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 A194A7FF for ; Sat, 13 Jan 2024 09:30:59 +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-vk1-f174.google.com with SMTP id 71dfb90a1353d-4b72e63821eso4603076e0c.1 for ; Sat, 13 Jan 2024 01:30:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705138258; x=1705743058; 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=bs8F5F/gFkaaibZRS33VN3FkQujN/mSOo0oKKTFy/VY=; b=kKBmfDYGWsiCc27z9hGDRNnpX1GS9S8cU0RSn8+MTR6HL80MR93N8ylCQLV6u7/2AP VnT3Y++4pn/5myHw7IW7xsZFNpUomLUVoWD1zuPfmv/P2WQhAQeH9klAqIjetQ3wo2V4 s/fCAilan23WgwyBGN8DxxzAdIPiNSpm/GAYTH0dlvsqXAS9D1MBL0xAm4QSh9aAKIgc z8tg8OeD+7yIPH5p0Pgxhj4SvaO33uRIuzihrA16CFOmnGB07ldHSATAr59uoSKgXzFc Qr+YZ2+YYb4wRsrmYoTJRKtNirwEn9FQhmZmng23cNUJQLyO1/TuxhDNB1Ax55sEqwiw C6Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705138258; x=1705743058; 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=bs8F5F/gFkaaibZRS33VN3FkQujN/mSOo0oKKTFy/VY=; b=FPlPjIZQ/UB87Kg9zXj5sUygXHiMCXrE9/yPPU2bLB1IhrZbGUz0WgB8BHq5WWm+Vk BEWfF/MUuW0JbYEFgb0gnzwyP0EPme6cQ7n7BYY0/2KWB2QZGVzOMAsCYPR+W7L6Sh5p v8I/bTpekZVB1YFKaj6ENKnbJdKa70i0pmOSeqzKjFiOeXxsoxs3yuiiLbqzTOIzxVZf fEnHf8mbVrVcVUf38/ArlDwDxPeGeZtdbpdfOTouQnf2PzeVa0521DiiSD85LHvIiM/O aukMc7b7ItMEb+8ETp475GUUgDW4CtseY8X0ibVJumnOKXqcPfjyMKF8vqAPIq9xbKO+ gpHA== X-Gm-Message-State: AOJu0YxdCorpJ+AegOgYQ1r5LS0FAfOlXZL+W3VPnqg62VQ8oT+8NMXX d993rh+oq2VaHZsFD71bg8cUPZNdOdncTrqGdLxL8CSMJevq X-Received: by 2002:ac5:c98c:0:b0:4b6:e3b6:41ea with SMTP id e12-20020ac5c98c000000b004b6e3b641eamr1766273vkm.4.1705138258316; Sat, 13 Jan 2024 01:30:58 -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:30:22 +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:23, Marco Elver wrote: > > 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? FWIW, the current version (draft) of this can be found here: https://git.kernel.org/pub/scm/linux/kernel/git/melver/linux.git/log/?h=kasan/dev I'll send the 2 patches next week - they should apply cleanly on current mainline. Thanks, -- Marco