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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66E6BC636CC for ; Mon, 13 Feb 2023 11:52:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbjBMLw6 (ORCPT ); Mon, 13 Feb 2023 06:52:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbjBMLwz (ORCPT ); Mon, 13 Feb 2023 06:52:55 -0500 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34875768A for ; Mon, 13 Feb 2023 03:52:52 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id v6so98919ilc.10 for ; Mon, 13 Feb 2023 03:52:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1TmLUW6hPremyHfH02mI1sZyfyvVZyCwA3fX+FOaBXI=; b=VMQNm0eiqoREYEAK7DXg+w4SBxCO4umzKJRt8APol006bSZpUXBrdJG6xAPuKFu7wF u5H/oktmJFRlzgGX+vF03cJq02hjSTH21rDe298h0DT33agIvlLq3EVK6vWIMnJxbPxB y2S6Chpx1brT7vYnKMYJhJXtUu0UH5SQuDwal5LGlv4Lz7AfbNfiBZEJcWwnoEdM0dyP QeiRznx8uqyecdyQc4Gn9/M3ZEsIjIvhOfL0fKDOg/pmJcwWNmY5YQ58axxmsv/YlMXn IlRuasdu18hKaMiZT4nvEAgGg4eH98U7Vhp56soBNjOoBT6EDn3Q4AzB95JXCCEuEFry S5HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=1TmLUW6hPremyHfH02mI1sZyfyvVZyCwA3fX+FOaBXI=; b=QxEhUW7qKYwYI5Ihmn7sS/qbKqF6On+5ouwD+NkqwR01e0CFtZOOaxbNfK/DzYuEIY PilA3xyY8y1XYzXGWrK/ASMFm7qFL3Ri1lYgQa0XABzrwXQw38IRCco8BGiL4GT8tIBn MLu/nNl/hXQ5qXQgc5+LykOYkVdUMA9aBmJsVWTfkGjbwzzOzbI+e+095lEh2/Xj7nYc vhB/PrDKCaUttW93b6EU8KI+2+udlWrvJBvLvi9Lf7H0qMUqC29dtJNfjSEc1/h+e0+U 0uf3A2sb1PdhDPoh3S+1Y4WzE5h4YHP7z1JQWXCJQFiqW+3vpTC3VNgz64m16DnxNMbJ QYmg== X-Gm-Message-State: AO0yUKVIVM2s5rF6owbvQkKn9EQ0TkvwfeDG7xy+pkErFtrbEw3/uPZQ Qlq08IcYTNGsp5Nl2MtTvqs0QVl7pzeFgkdXAe1E3Q== X-Google-Smtp-Source: AK7set+Jv4HZl0nSf1uZg7MOawEojcn8ISEv4W9PIqKYmccB/VLVVt+9l+W+zQuslLejUuemhSR18qAuVCNghXpzs0I= X-Received: by 2002:a92:8e43:0:b0:30f:5797:2c71 with SMTP id k3-20020a928e43000000b0030f57972c71mr13118156ilh.51.1676289171334; Mon, 13 Feb 2023 03:52:51 -0800 (PST) MIME-Version: 1.0 References: <359ac9c13cd0869c56740fb2029f505e41593830.1676063693.git.andreyknvl@google.com> In-Reply-To: <359ac9c13cd0869c56740fb2029f505e41593830.1676063693.git.andreyknvl@google.com> From: Alexander Potapenko Date: Mon, 13 Feb 2023 12:52:12 +0100 Message-ID: Subject: Re: [PATCH v2 16/18] lib/stackdepot: annotate racy pool_index accesses To: andrey.konovalov@linux.dev Cc: Marco Elver , Andrey Konovalov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 10, 2023 at 10:18 PM wrote: > > From: Andrey Konovalov > > Accesses to pool_index are protected by pool_lock everywhere except > in a sanity check in stack_depot_fetch. The read access there can race > with the write access in depot_alloc_stack. > > Use WRITE/READ_ONCE() to annotate the racy accesses. > > As the sanity check is only used to print a warning in case of a > violation of the stack depot interface usage, it does not make a lot > of sense to use proper synchronization. > > Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko