From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A62D27FB05 for ; Mon, 1 Jun 2026 08:05:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780301160; cv=none; b=ozo/FeVcvYjO7O3i5r8dZzl1XVCyR2o9Ts9x453M4JiYUQApKcwXWUcxxRQ+50BBeWXIl2oB2nPOMqmpj32tC0NLAsei16qLGN5MGeG93GOTi099eCak+ZVcjDvNILricpAsixcXSLhQWdtGSZGk/WzBskxKCGu7FpTLyzx6DY0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780301160; c=relaxed/simple; bh=sK+PVnbXl5f1Nrv5/wH11T0gRYuvtUH9QYxZA8d1PR0=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=K6zT8wNMr6GxEodKenHKn/PWCZi4/OHewcoKyIRHQwRtgBTZhEUqVGddcQmBPQ1M2I0krLgrCUakOIH5GoyLxUGWxL80LEHcDz80Da8mRot70ns9Qtst0pBy64xJTCIyIxvG1nO7+7fnCdQZuhIzMSVBGKsESFZFHXYgkS+JRTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=cFHu2cGK; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=h8ZT9G15; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cFHu2cGK"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="h8ZT9G15" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780301158; h=from:from: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; bh=U/RZ7wJj9UMIWugVWJxqvoVLjTFNGaBYPTyCaZ96To0=; b=cFHu2cGKK3xJ7ndR/nlorOhc206Z3o+yI3RtbSLoXwdkYayBD7tY9DUoDLDeunfEeH+8wo q2oA3079f6NCSV7JUIU7thIjxtMB9WrfJJeDHJiKqtsjeWEqUracgTMc3K0k7vQg1ThtwU cPtlL3owPRMgUB/Hrp2OzoJq05SLWg0= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-344-4n-EmgbuMimY0NujbkwceA-1; Mon, 01 Jun 2026 04:05:56 -0400 X-MC-Unique: 4n-EmgbuMimY0NujbkwceA-1 X-Mimecast-MFC-AGG-ID: 4n-EmgbuMimY0NujbkwceA_1780301155 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-5aa5b598829so1574069e87.0 for ; Mon, 01 Jun 2026 01:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780301155; x=1780905955; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=U/RZ7wJj9UMIWugVWJxqvoVLjTFNGaBYPTyCaZ96To0=; b=h8ZT9G15n3zhqQQBRppg0lSZBNFl71lvopMGUWYT9q1QQWFersybfim/TlOILccn6D F+b2tRt1yB19xYI63VD3GC7ZY0PGPvqY4dMONK2X9GIGrBTylcYxtg8psAddJo5bvIWA w2FGYOJYB+iCyJt7HQQNKHf146Rti1reoNr3pWgiQhejOTzqa2gfV9gPpEJV+gfiwYcb psJFfVzEFbt10ALnDwIXP8rLAZKuCSC7t6eO5zAXzF3K/hYqq9MNPhgawqKCUPIiKoIE oOH4CjjRMmP7u5ZGF5k7KV2Ni/fPOt3TR6hQqAZHvQQ58a8A2qLVfAWrQ7wEu4E8LJYl eMFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780301155; x=1780905955; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U/RZ7wJj9UMIWugVWJxqvoVLjTFNGaBYPTyCaZ96To0=; b=Dw56iU9I5/C6MaBWvJ746pY4EsjehLVYqMvlZMAbJWh0/LyKg3VBtIc/J1/g7yV3Oo 8+Uy8cYgYioSUPPDhntA+kvhsgqU32MHR90+W/sdNuRoH24m3AfcdROBZ/NLGu2gghWH HnSa2OHcPcvkzMNzocwoU8X0GpYHDO93Yyba1hCgJDYYM4+Rdyh/UYwuloHrmnSIMZO8 tZGYHlWvd7zc9dMxuQ+0HSYqxCO/U+2HAMB/KVGknEs9JlRuk4mTwdeh1US+aaCy2XZJ eEdXf6KKgam3XHc4k5/S1fjEAWrm29eDeAs0WF/YStWrfXIrTknvajAK/JqpiPBbcMsS 5mSg== X-Forwarded-Encrypted: i=1; AFNElJ//IoSDZ5qcDkc5uHA6cvuO19nNSLLMCSoIXzar3qoPzaFEQI2xrhKIRXXwDXAVv6ze5SPswXdlInrV1fc=@vger.kernel.org X-Gm-Message-State: AOJu0YyxaZmQMSUAXZfA1XbAppPNWTu8vbcdbkH7J0gDazaU4R+GQr18 PF8t7kEjAbZgtOqRJlPJKJLrKBWi+wxCJkDsqF/kuhBwkpXvZZX6zbN3RIpCYnnRqX3PcBlxL/B 3BcjoNC3QVb751NH6qcsUl90PN/o58ihBjsyujUCsRK9CsIV+ouJAelkhfrGY/MSqlpht+w+HZg == X-Gm-Gg: Acq92OG2hQhy3WjjGW9J7mRnIhQL7b7PBRfLYAxajk3fMftphjsiqf9b2gN6JpmNIte yGQWXdOzxhncxu+0ok8reqdlNW+huix7fTs+a58Qfo6OqJP3XgzI+Tsskwz8u/Pe3ipoqFXVfBh RCa0Nl8ldj76yTI1Ecc6/Q34UIuNLlz2gCt+Xb9vAhdacieJbgJRqU9HkP6g0ORgaopq7eV4gu/ 6tV99gVwszJ/7HWTw5r9ct67hXKeyUT01MiXReVhWtMpyM1ih1bs1hoau5JNncsa2NN3zWOMR7p vm7+1JJd29pcY6YAoCpSrZcVtmcOZw4ZX8ESqJVzrI7P6bLZlKvkw67kRZ+4tS3lk+puRD+bBOE v41g6OgmrZgJ4e3ZOL9wymAmL2dpFK/J9Ghsk X-Received: by 2002:a05:6512:3c9a:b0:5aa:6869:2bec with SMTP id 2adb3069b0e04-5aa68692d92mr1654216e87.27.1780301155085; Mon, 01 Jun 2026 01:05:55 -0700 (PDT) X-Received: by 2002:a05:6512:3c9a:b0:5aa:6869:2bec with SMTP id 2adb3069b0e04-5aa68692d92mr1654194e87.27.1780301154557; Mon, 01 Jun 2026 01:05:54 -0700 (PDT) Received: from [192.168.1.167] ([185.168.96.228]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef34c50f6sm26121629f8f.16.2026.06.01.01.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2026 01:05:54 -0700 (PDT) Message-ID: <53a0e047a12186b4b9b2c7e4c6715842b7c3bcb7.camel@redhat.com> Subject: Re: [PATCH v3 08/13] rv: Ensure synchronous cleanup for HA monitors From: Gabriele Monaco To: Nam Cao Cc: Wen Yang , linux-kernel@vger.kernel.org, Steven Rostedt , linux-trace-kernel@vger.kernel.org Date: Mon, 01 Jun 2026 10:05:52 +0200 In-Reply-To: <874ijmy9xj.fsf@yellow.woof> References: <20260530141652.58084-1-gmonaco@redhat.com> <20260530141652.58084-9-gmonaco@redhat.com> <874ijmy9xj.fsf@yellow.woof> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.1 (3.60.1-1.fc44) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2026-06-01 at 09:52 +0200, Nam Cao wrote: > > +/* > > + * __ha_monitor_timer_callback - generic callback representation > > + * > > + * This callback runs in an RCU read-side critical section to > > allow the > > + * destruction sequence to easily synchronize_rcu() with all > > pending timers > > + * after asynchronously disabling them. The ha_mon_destroying > > check ensures > > + * any callback entering the RCU section after synchronize_rcu() > > completes > > + * will see the flag and bail out immediately. > > + */ > > =C2=A0static inline void __ha_monitor_timer_callback(struct ha_monitor > > *ha_mon) > > =C2=A0{ > > - enum states curr_state =3D READ_ONCE(ha_mon- > > >da_mon.curr_state); > > =C2=A0 DECLARE_SEQ_BUF(env_string, ENV_BUFFER_SIZE); > > - u64 time_ns =3D ha_get_ns(); > > - > > + enum states curr_state; > > + u64 time_ns; > > + > > + guard(rcu)(); > > + if (unlikely(READ_ONCE(ha_mon_destroying))) >=20 > Instead of this global variable, can we instead use da_mon- > >monitoring? >=20 We already do in da_monitor_handling_event(), this is guarding for the very unlikely scenario of: 1. timer callback firing (just before guard(rcu)) 2. sync rcu, return before waiting for that one 3. reset and free memory 4. guard(rcu) now and check the state in da_mon (freed) I'm not too confident saying this cannot happen under PREEMPT_RT. I know the easy alternative would be to synchronously stop timers on destruction, but that gets complicated with per-task monitors, where we iterate over task grabbing a read lock. Am I just too paranoid? Thanks, Gabriele > > + return; > > + /* Ensure consistent curr_state if we race with > > da_monitor_reset */ > > + curr_state =3D smp_load_acquire(&ha_mon->da_mon.curr_state); > > + if (unlikely(!da_monitor_handling_event(&ha_mon->da_mon))) > > + return; > > + > > + time_ns =3D ha_get_ns(); > > =C2=A0 ha_get_env_string(&env_string, ha_mon, time_ns); > > =C2=A0 ha_react(curr_state, EVENT_NONE, env_string.buffer); > > =C2=A0 ha_trace_error_env(ha_mon, > > model_get_state_name(curr_state), > > --=20 > > 2.54.0