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 DA66DC636D4 for ; Tue, 31 Jan 2023 21:14:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75D5D6B0071; Tue, 31 Jan 2023 16:14:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 70DFA6B0072; Tue, 31 Jan 2023 16:14:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D5106B0074; Tue, 31 Jan 2023 16:14:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4B5336B0071 for ; Tue, 31 Jan 2023 16:14:15 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1890FA03E4 for ; Tue, 31 Jan 2023 21:14:15 +0000 (UTC) X-FDA: 80416347270.07.D36C124 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf29.hostedemail.com (Postfix) with ESMTP id 07698120007 for ; Tue, 31 Jan 2023 21:14:11 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=i+eNCGEG; spf=pass (imf29.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675199652; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WoAyIb2wqJPoULrOHXdzqBUyUUSgJtNqiWx7gfoyZ7Y=; b=qB0qt7LfFAmriSA4vzT9qSkd6isUpYwnw1WvBJ2JgfJ/PHk9F6MokahC2RsQR5WnNN+0NQ xjw3ZK7yhEDErYloIMNjfjAEjseaBIHplevGiHO24xwKINiZtY084koif1SUfIpZHt3ApD 2qtk5/Q0cgMt8afW66ibVH5hIVknYFk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=i+eNCGEG; spf=pass (imf29.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675199652; a=rsa-sha256; cv=none; b=EwSD46Cd8EYvujQcEeI7FbDeXnIptLCag65NvAm259+T4r/k0H2TApwtjypw+1Awav8Ywd LydgAwRIThzdqXiUEXujSA5OQXQIXoTrxKxGoQvTrDkUT6sVVimYRUlR9f72oXBuhTH3DC 9c+jYOQd//tGeH+kmWJQyDU3N9/SfeM= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7C234B81E6C; Tue, 31 Jan 2023 21:14:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA18FC433EF; Tue, 31 Jan 2023 21:14:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1675199649; bh=U6wsVUmsmxWrp6Ky3+Emxba7PMvSFL11l7NlSfpF6N4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=i+eNCGEGJlXeSZ9fNAjQ6sx9GTx1CbjaGju/Lz3FLdukpacSy/wSs4Ji1oiaEBHZu QFbw28Bp+O+MqFxekxTKNNs8U64vPSFbcKbPmk1zWavqtWZTfiI2nv+MRyf61dckus n1YCHygo1GSUHPnNYn1gE4upjXjOMJYCvrx7hSYQ= Date: Tue, 31 Jan 2023 13:14:08 -0800 From: Andrew Morton To: Andrey Konovalov Cc: Marco Elver , andrey.konovalov@linux.dev, Alexander Potapenko , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: Re: [PATCH 16/18] lib/stackdepot: annotate racy slab_index accesses Message-Id: <20230131131408.ceea0a762d45bf94c1387367@linux-foundation.org> In-Reply-To: References: <19512bb03eed27ced5abeb5bd03f9a8381742cb1.1675111415.git.andreyknvl@google.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 07698120007 X-Stat-Signature: o1skaf3jb34x5oin59ydmddnjwyzhhgq X-HE-Tag: 1675199651-68804 X-HE-Meta: U2FsdGVkX1+BbHG+z06goXdU2tahk3lDXK5yYrSGZ2A7uPkyGsjDS5oFPkz48uNcziwGeoPs5ozMohPxmNn+6dcsW4+0Y9C0BJqProSOmQq1OIqFJeiL6sqfR9dQ33ksLS1NUwxrK4m+TW8DBPAuedNwMVWg8HjyrtieYUxIa+63sDLR19yWTcsAPuaLwdfgf0xHLnIDDmQLXOLwSdrTaFFiOkcFzOt69nRao9PD5FhMFyR3WYBjthG92tKw9QmGWOCkO7MLvvpeHpiDWm/S2D9yOeIYn+/cJpvICKkF6z1amTBep4oMVqujkKWyIkTkGGKMmqUDXMVWUuQ2X+AOXYo7g/0nhgJZ2z/R+QobWJgZ59rXdhvmIptwkHrTmxvFwlYPBGAIrALN9xuZt5wlL1g2Z0H6zjk3nOc76bnNC5csvyIV5bUebF7xuinAuNMVLqnd8Vs5F3vpOtppzejHhndVws9259GdwzVRrj4tLwIfkML/L+STJ54hqDeoPsJETEbHa69eOk/508aOq8kC+Mm6GWeFRBOhDeM1YUy8s7X17wAq37DMdCMyZhQpk43Qd+M0RpJOa/hB5zDIn3xzRA/bNRIsjlPvaDPMdyp3/2Ug7D8mSHF91pciGxwvXer1swsLHz7Dgltptmv0ZivmdxZSNL3ZrFb8373sX9ahh0NNsEev7PBunqPk0PDbYAxOwSYFA0NG6AkzVWYzhKyRy3BHxq5UGjwKierUwtRifhf57tGlbOczt4fmRDSgzMW7x1EwkASIVlUBqHBlJ2K3Hm/wDcc95NgAlYLGbIYbBJsTEQu+tk1JSi54RHVOFyS3VFY7JfrRipDmz176ZHEwkaPv0VzxrB7kbge3k0TlTJnHoLwsQwZLIqBaU/OgzF4VuIFCWM38XZxxCKzO3WANhirT5ddEIEf3DNaJZnb+2mOlpMtfw9xwxdnPpXcno/sWpbMUllZ3i7MMJkFGvsS MyGDXItF a447xbDvWnSWrDY3qcdxxRJHIqCz8ZV4y+jFhqKn4R8OJdXCs88dInlGhC12bqCHDTPL4GUVdT4PA0L4l4M5mUTN7VS3SiDPntfskiKHjd1xwIixGK3mSJLEEb+4DKPpjTt5ANrdVjKBe+JhPb52s0OKZaUeTf2Sd7/gqh8RDv/T6eJHisZUiaFLPAnj0p2pRK7ehjNOlXP8hqARNiwYdCdebuDq3RisbDGXbDamnpmkfyHTy3lMHAzcGK0OKENEvz19CNlMuiwSeJQFX6t2QJRD3T5XzV/4AcWfr/3IODkgYZwG3vKOlKDi0CGWkpVoWDsohNDkscZSCHAHTWFewkgMLQpAYFh6CGYnB7a90ju7YJFATuhcp3A9f2STDy0Z47m5kEFHAIPpyY0UJeCA1IWJ5Suylc+qQX8vDuEJjZNued1G3GNf9feQSmuSFRjlqpY7MYCh8owky63U/egCBLrvwteFJKbOwDAGFuyC3ukPEHdXaHGD1oFUsdw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 31 Jan 2023 19:57:58 +0100 Andrey Konovalov wrote: > On Tue, Jan 31, 2023 at 9:41 AM Marco Elver wrote: > > > > > diff --git a/lib/stackdepot.c b/lib/stackdepot.c > > > index f291ad6a4e72..cc2fe8563af4 100644 > > > --- a/lib/stackdepot.c > > > +++ b/lib/stackdepot.c > > > @@ -269,8 +269,11 @@ depot_alloc_stack(unsigned long *entries, int size, u32 hash, void **prealloc) > > > return NULL; > > > } > > > > > > - /* Move on to the next slab. */ > > > - slab_index++; > > > + /* > > > + * Move on to the next slab. > > > + * WRITE_ONCE annotates a race with stack_depot_fetch. > > > > "Pairs with potential concurrent read in stack_depot_fetch()." would be clearer. > > > > I wouldn't say WRITE_ONCE annotates a race (race = involves 2+ > > accesses, but here's just 1), it just marks this access here which > > itself is paired with the potential racing read in the other function. > > Will do in v2. Thanks! Please let's not redo an 18-patch series for a single line comment change. If there are more substantial changes then OK. I queued this as a to-be-squashed fixup against "/stackdepot: annotate racy slab_index accesses": From: Andrew Morton Subject: lib-stackdepot-annotate-racy-slab_index-accesses-fix Date: Tue Jan 31 01:10:50 PM PST 2023 enhance comment, per Marco Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Evgenii Stepanov Cc: Marco Elver Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- lib/stackdepot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/lib/stackdepot.c~lib-stackdepot-annotate-racy-slab_index-accesses-fix +++ a/lib/stackdepot.c @@ -271,7 +271,8 @@ depot_alloc_stack(unsigned long *entries /* * Move on to the next slab. - * WRITE_ONCE annotates a race with stack_depot_fetch. + * WRITE_ONCE pairs with potential concurrent read in + * stack_depot_fetch(). */ WRITE_ONCE(slab_index, slab_index + 1); slab_offset = 0; _