Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6224886rwl; Mon, 9 Jan 2023 05:56:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXscU/C1RaORsieR5MjT9m+1unKkzajJ5M51+t7tAYEA/J23uyHRYnzpZl3hO+gEg8brEDMT X-Received: by 2002:a05:6a20:43a1:b0:b1:d250:d08c with SMTP id i33-20020a056a2043a100b000b1d250d08cmr79851374pzl.36.1673272561841; Mon, 09 Jan 2023 05:56:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673272561; cv=none; d=google.com; s=arc-20160816; b=iS3JLNYjdugxBDAY5WKAk9ZLJ3dqruulXkylw4Kr+8RGhqEnsf44wb91/rwkh6bCzr R1WDyWrKT1vif7phxNdKX7xQ8BEareqCT3mXSTos7HagovAILxPcWtXPGltwAnH8U8Nv +28eNA+BhZyv4ByUHQV1q4l7h361iy4KP+KgkI5j22c2y88qaHP7XZZItJlWEqd/CUuT 3hwu+AKeTnHo+roYE5Tz8ovfMdaq9MO1NwRQhJ1SONGzGi/EIRQPK+wEVO1i5Af7qiza sY3dv0QYc5p8G0tDt2adIBrZD4YZHWtm03odP3d+Om1+S2ejENlkV2zHP9e186nDgzun kdvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RUPWQ00I4B+FeAT4uW8sz7LlGf270FM7v3Ovcdol5eo=; b=nT7U+rdgelb7m71O9J4C1IkpbcVvC3pO1Xp+W7z9q3C0qfc+ZPLDpdNRJCn37OjdhQ MaEGGQQ/ukVduEMoNK0NFSyIgqDxkGSlgy8WAKC6umwZ68pynhD4pH4gNJd/OtmpydAN Ucrwf9EI2sjo2qLlgra4cYjYN/m9V4Gc9/8L6Z6t87wR4oGLgWk58qjNAPzl2A6p19gU sT+yIXiTRLCFFx+BiGd5rHEEXRcilivUK+0ZKYOLjmBslKVNRr3FFjnZUKAyUJZidsld NVOH5R3tKfI4cU0VjFtXsffrLlK/TrbkcXeEPG4Y9spz/KP2SE0dxQW7nQA2qaM+h7uJ boUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dNoYjm6G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a63d341000000b004792b08adabsi9388691pgi.750.2023.01.09.05.55.55; Mon, 09 Jan 2023 05:56:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dNoYjm6G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236471AbjAINOU (ORCPT + 52 others); Mon, 9 Jan 2023 08:14:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236428AbjAINN2 (ORCPT ); Mon, 9 Jan 2023 08:13:28 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31B52F2C; Mon, 9 Jan 2023 05:13:27 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso12762973pjt.0; Mon, 09 Jan 2023 05:13:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.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=RUPWQ00I4B+FeAT4uW8sz7LlGf270FM7v3Ovcdol5eo=; b=dNoYjm6G2UptA+miOjROgT/3AYYHiuu0qY1GE8xiov6fo0JV/29wYEpFRR0aspzTEM Y+3lJ7m+F3vwEsCU9+WSfDH51n7JRARreaSrvHJPegJMlClrsaVkLGQFopidghxYZMAa LcojnCYBZ/ndV/8vidGnxhZpjZPQUbHLyLj+raYZFdrFQ8fRIQtfoyZwLoU9fo6KzJkW ASe1ES1EyB5CzD+ZdEVbiDhEaU3ktVOrJAQ5KVOyoPhEFXHfoqNBl8ebpgAxKO22jKPZ 5EGR3oiyYdZKnpNH5peYAVu5P+aR/dhUotlQhHP535ugn7Gm/Ys8B8L+5yjbkv3M291r n1qA== 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=RUPWQ00I4B+FeAT4uW8sz7LlGf270FM7v3Ovcdol5eo=; b=SHGvfdUYxCAnAKu1UtFZmwR6iIZ/aD8P+rBzIQehtnHqDvL4gTFoFETkoQMskO2B7k qesqMBwh+r+8g3uQPNKqjMAwwfisYczZg5zmOsoR4QHrS1xkY7J1A39lw1pgXaltrDbt cDwbEgIIzwfvnr5+owHYVbDCOgfLZ+OiFdCZs6Jvfij652JPRA1u4jzsoLkO/Pu2nAWO E/hezRRzaDWpJWuhxVfFY+QOOgHyJHx4GFT4Fb4aNUaze1QigEGNRBMOU3nlk0j1JYfe VCf1o3LYAAN5NOPv5ZNUJ/A9QuUVJOwq06Ek9XJxwhDZ0j5q3wcxgUN7UoDeqp2p/gdx ZTgw== X-Gm-Message-State: AFqh2komwUvizQy2eBOqfHcV+6dcoB6UqIyL1AOztxedVBqqOEh4qQGr XWVU+z2ocN7K0c1P6LznPh5KJjPZTx/VSFI0tw8= X-Received: by 2002:a17:90a:9b17:b0:226:2a7c:9ba9 with SMTP id f23-20020a17090a9b1700b002262a7c9ba9mr2509758pjp.128.1673270001870; Mon, 09 Jan 2023 05:13:21 -0800 (PST) MIME-Version: 1.0 References: <20221219052128.18190-1-zhouzhouyi@gmail.com> In-Reply-To: From: Zhouyi Zhou Date: Mon, 9 Jan 2023 21:13:10 +0800 Message-ID: Subject: Re: [PATCH linux-next] mark access to tick_do_timer_cpu with READ_ONCE/WRITE_ONCE To: Frederic Weisbecker Cc: fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org, paulmck@kernel.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 9, 2023 at 8:51 PM Frederic Weisbecker wrote: > > On Mon, Dec 19, 2022 at 01:21:28PM +0800, Zhouyi Zhou wrote: > > mark access to tick_do_timer_cpu with READ_ONCE/WRITE_ONCE to fix concurrency bug > > reported by KCSAN. > > > > Signed-off-by: Zhouyi Zhou > > --- > > During the rcutorture test on linux-next, > > ./tools/testing/selftests/rcutorture/bin/torture.sh --do-kcsan --kcsan-kmake-arg "CC=clang-12" > > following KCSAN BUG is reported: > > [ 35.397089] BUG: KCSAN: data-race in tick_nohz_idle_stop_tick / tick_nohz_next_event^M > > [ 35.400593] ^M > > [ 35.401377] write to 0xffffffffb64b1270 of 4 bytes by task 0 on cpu 3:^M > > [ 35.405325] tick_nohz_idle_stop_tick+0x14c/0x3e0^M > > [ 35.407162] do_idle+0xf3/0x2a0^M > > [ 35.408016] cpu_startup_entry+0x15/0x20^M > > [ 35.409084] start_secondary+0x8f/0x90^M > > [ 35.410207] secondary_startup_64_no_verify+0xe1/0xeb^M > > [ 35.411607] ^M > > [ 35.412042] no locks held by swapper/3/0.^M > > [ 35.413172] irq event stamp: 53048^M > > [ 35.414175] hardirqs last enabled at (53047): [] tick_nohz_idle_enter+0x104/0x140^M > > [ 35.416681] hardirqs last disabled at (53048): [] do_idle+0x91/0x2a0^M > > [ 35.418988] softirqs last enabled at (53038): [] __irq_exit_rcu+0x6e/0xc0^M > > [ 35.421347] softirqs last disabled at (53029): [] __irq_exit_rcu+0x6e/0xc0^M > > [ 35.423685] ^M > > [ 35.424119] read to 0xffffffffb64b1270 of 4 bytes by task 0 on cpu 0:^M > > [ 35.425870] tick_nohz_next_event+0x233/0x2b0^M > > [ 35.427119] tick_nohz_idle_stop_tick+0x8f/0x3e0^M > > [ 35.428386] do_idle+0xf3/0x2a0^M > > [ 35.429265] cpu_startup_entry+0x15/0x20^M > > [ 35.430429] rest_init+0x20c/0x210^M > > [ 35.431382] arch_call_rest_init+0xe/0x10^M > > [ 35.432508] start_kernel+0x544/0x600^M > > [ 35.433519] secondary_startup_64_no_verify+0xe1/0xeb^M > > > > fix above bug by marking access to tick_do_timer_cpu with READ_ONCE/WRITE_ONCE > > This has been discussed before with passion: > > http://archive.lwn.net:8080/linux-kernel/1C65422C-FFA4-4651-893B-300FAF9C49DE@lca.pw/T/ > Thank you for your guidance, yes, the discussion is very passionate ;-) and I learned a lot from the above thread ;-) > To me data_race() would be more appropriate but that would need a changelog with > proper analysis of the tick_do_timer_cpu state machine. I Agree, and also I learned to do more rigorous technology research. > > One more thing on my TODO list, but feel free to beat me at it :-) Thank you for your concern ;-) Thanks Zhouyi > > Thanks.