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 917B1846F for ; Mon, 1 Jun 2026 07:51:51 +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=1780300312; cv=none; b=tZqdyDJFd+9qpAwLzaLKoBXKQHbEvXw4n8Mr4QyX9mZNQZ3B/liw5/JUt3xgUb9HvUyWbUs4Tp/GoD4RNEt4TxBboG4+d8++n3/nIeX2I7yhgIoKXaIiZFDcmxXSYl+hCZCt0XLVaIfEBVZSkGFm6B+IbbbqToifOxxu1H5fAkU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780300312; c=relaxed/simple; bh=uGtQ5yEwPAKisDcKlJevbvkY/xFV1k3S0qYOdLtxFe8=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=eyV5A4IMn8GpCBlwZIFcDaVk1+mFLAcWicA16Bx9sw5WScwTdCHop/v3Txm7iGLTcouoj7oz0HlwnWxqbhj+CkSRsQ1IBV+3RKAH+Uj2Y1MWYprZyk0nyuBgZR5durGgqKwOpuZ9Xr2BgIgWKO4FwcZoahsjklj+5MvgubBXclY= 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=WEG577BK; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=kes4RXqH; 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="WEG577BK"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="kes4RXqH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780300310; 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=tE5GTkPw868kwEOFbb8DCyrZt7dMlF83XvmEKjd+iyw=; b=WEG577BK9Ua7UKTv8WemFnYbxcs+l/qYWvq4dSAAg6gsrOWq19fj6j8EZ8BGhoKvNh58A3 wOWE43Ph4H8f1jnS2Iuv24M3xw/mEw+OIYfQU7BYiLDnfF1CZCw3O4mCnNrIir1J/cuxC7 Qhctp7a247apdAShT+twKXY7NcSVobo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-190-MOT3-Yw9MZ6PZl2qmBpcZw-1; Mon, 01 Jun 2026 03:51:48 -0400 X-MC-Unique: MOT3-Yw9MZ6PZl2qmBpcZw-1 X-Mimecast-MFC-AGG-ID: MOT3-Yw9MZ6PZl2qmBpcZw_1780300307 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49058295985so55096455e9.2 for ; Mon, 01 Jun 2026 00:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780300307; x=1780905107; 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=tE5GTkPw868kwEOFbb8DCyrZt7dMlF83XvmEKjd+iyw=; b=kes4RXqH7uQcgex1ZcI18zGw5rbNv57TKcvLoBl6XpE54iVWQXJwvCvH5jDGnYZnJr GhJUCaKUqsAfx+jKZUearL3kkhi2vaULPTzcj6FjiavpctZaEcrLzuZvf90dXhxIeZ98 oLXTdOy0TiuBY3DUO7xW2Tlxabi3qxR28AsdnNdvU8Q18wis/cT0h+E8peFKupRgNrId uffHCYiP/62AvK3Jx2IFKiBC5c6FieyP5aRh/+JC7HGfBVot+Er4WuGlYx95oDo1BTXH UdOyFRoCLTXQXLt1KjCKjhGeKOh4cN0teXHnJukVHDInTk8ZcsD2UGjrcpeZYX5ooHGs JZ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780300307; x=1780905107; 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=tE5GTkPw868kwEOFbb8DCyrZt7dMlF83XvmEKjd+iyw=; b=rnKWQ0TLqgMiV7lDfyQjlat5k2BO8Y1lu3Ehz7iifQxNRXb+gDtwQ4Oc7g2hBMjrw2 IWJpmoAUN/y4il352UlUjTyHHrIVYkp5M8NDCjKNGoMb+dMRP+gLF1zL4cpOH8yi1FuO gSfrW11fmdzxt/uSzFw3MN0D4CoSyUGVaVH3VqYOYoQYxRUQULIhT+6ya7Yxjjm2Nfr7 Sa4LF7CSKfHJ9HgSvm54tmoWWRJN+4ZQOSB3WfWFfuGqGZsZ3jeUgH1qOr1HyG8K4mq3 7SQcP/TUg1LH86Knc4OEgtvMu/ukIjC2t20MV4bxr0ZvzbYSGKPGJR8psjl/nWE5j4Zv Yhxw== X-Forwarded-Encrypted: i=1; AFNElJ9J2uT+rw3K6Vw+mcezd/Zo6qFo5w1WIiCiaVf+iCBagBKcoSeuDBLGDFa8s4mvbtSqH4lRJG0HhZA7gec=@vger.kernel.org X-Gm-Message-State: AOJu0YyWvDmnB/vuESjz4J6i/H+NBMb85kYEDx97MJPaTdGqXgs67D9m CPRJqATJ6gfgcbpqt+Oi5GjYuKYk/1wWchkTgvJrNyp9H1RCwmvB9dzHprfKEfIC6p83R0PYNac 4rCkIijL2VczG05cqPhO0hCcN7TL6qWaodCi+uCt72CPS+AuvVQjrv4BtdWMz/ltkvg== X-Gm-Gg: Acq92OF1TvSA0n4vZAcre+2KH1coOAwJuLUZSVm3aRvwOz/Qr8uqJOBHhp12L5Zi5Ku bxK99Bq+tMFTcGYYMmuau5t3MutieJuK3EgUgpfHXXxmJzIZ2T43MZV2gmIJoQeCLtqH5ti3A2s +Q+se5j2JA9JSZtPpvEjptDKrK4jk664G5rLr2+A5wNMKWnrhb4a6Qwn//J+4VCVm+TLMoSIx7T dsUjn75UIe6u7rvRf+lM21GvSOonboiJfsWGVmQFpEQjBOnNdmeM3QBJVVW9/iyetH8voMuqXVk ExnKi2O8cSyhFPowPGVXQgtRCbmaPdZh4UCG1lWJ7/mSezjsBnQlZCuMnnkcVkD4PWtoDlmuSxE tP1JVXEehchzci/tR/GIr/rneoFOWD5dNWFdU X-Received: by 2002:a05:600d:6402:20b0:48a:58ae:9938 with SMTP id 5b1f17b1804b1-490a2933aeamr124314665e9.19.1780300307185; Mon, 01 Jun 2026 00:51:47 -0700 (PDT) X-Received: by 2002:a05:600d:6402:20b0:48a:58ae:9938 with SMTP id 5b1f17b1804b1-490a2933aeamr124314335e9.19.1780300306766; Mon, 01 Jun 2026 00:51:46 -0700 (PDT) Received: from [192.168.1.167] ([185.168.96.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490aab4f87esm10940815e9.22.2026.06.01.00.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2026 00:51:46 -0700 (PDT) Message-ID: Subject: Re: [PATCH v3 07/13] rv: Add automatic cleanup handlers for per-task 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 09:51:45 +0200 In-Reply-To: <877boiyaig.fsf@yellow.woof> References: <20260530141652.58084-1-gmonaco@redhat.com> <20260530141652.58084-8-gmonaco@redhat.com> <877boiyaig.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:39 +0200, Nam Cao wrote: > Gabriele Monaco writes: > > @@ -123,12 +144,15 @@ static int ha_monitor_init(void) > > =C2=A0 > > =C2=A0 ha_mon_initializing =3D true; > > =C2=A0 ret =3D da_monitor_init(); > > + if (ret =3D=3D 0) > > + ha_monitor_enable_hook(); > > =C2=A0 ha_mon_initializing =3D false; > > =C2=A0 return ret; > > =C2=A0} >=20 > What if between da_monitor_init() and ha_monitor_enable_hook(), a > task exits while a timer is still active, and then the timer callback > is invoked? We are initialising, timers shouldn't be active, that sits right before setting up other hooks, and the exit hooks this way is just the first of them. By the way, in this case, we likely have a valid reset scenario on an invalid (uninitialised) timer. This is also what checking the monitoring flag guards against. In short, in that handler we really should reset, but need to know whether we ever initialised in the first place. > Extremely rare, but I think it can be fixed easily by reordering the > two functions. >=20 > > =C2=A0static void ha_monitor_destroy(void) > > =C2=A0{ > > + ha_monitor_disable_hook(); > > =C2=A0 da_monitor_destroy(); > > =C2=A0} >=20 > Same here, there is small window between the two function calls. Likewise here, we removed all hooks, then da_monitor_destroy() is going to sync with them and clean everything up. Swapping them will expose more races because we dropped the slot by then. Am I missing something? Thanks, Gabriele