From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 9973D45AAE;
	Fri,  4 Oct 2024 14:00:20 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 6F43140E5E;
	Fri,  4 Oct 2024 14:00:20 +0200 (CEST)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.129.124])
 by mails.dpdk.org (Postfix) with ESMTP id E823A4027F
 for <dev@dpdk.org>; Fri,  4 Oct 2024 14:00:18 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1728043218;
 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=AbbhSE5gagSCzIjdE8SkktydlfWvtiGk+Em5wVReasQ=;
 b=cMSbFajrNmhLapR6g2vEWVqcnU477sv224EC+O0li3XoiApkLLq3qsS9TSUUYqIca3pjcX
 DfO3OWIqU8MIAtpYvZOgqWyv0CCDSmyCC05ghaNbsDIyzKWOSaGm39ylOQ0rU92pBCtJa8
 LmRnyLzM9F8sIDwVJiqx7WGfZsBTQc0=
Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com
 [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id
 us-mta-629-Djnz5lAEPv6H3W29_ijJjQ-1; Fri, 04 Oct 2024 08:00:17 -0400
X-MC-Unique: Djnz5lAEPv6H3W29_ijJjQ-1
Received: by mail-lj1-f198.google.com with SMTP id
 38308e7fff4ca-2facce1b62fso16354171fa.1
 for <dev@dpdk.org>; Fri, 04 Oct 2024 05:00:17 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1728043216; x=1728648016;
 h=content-transfer-encoding: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=AbbhSE5gagSCzIjdE8SkktydlfWvtiGk+Em5wVReasQ=;
 b=q4NytM7RQ8YLF9xvbkgjE3cj/th6hA07yufFjsvj9zgKTnrewgFLMwakTYlDPgyz1H
 aMQcLub42Yz/861yzHotFVPoQvSBq2PtWcT0y86z3O9D0mon6a2ZRYxnqpAT0mEoSOAr
 A2q4boc1WmefsWi8TOWOFYKPVx+PRBkNQ7wlGz171fILBsh86eXHerFlckDq50t2yadi
 fytPgXeyFEzKJXt/5FA3zGoh7HPo44HwPzkITp59uh5uJRLTCZ8irBfSmqK1GkW99Chi
 WH7V97QcgU3wpZjpCfgDDpoqk0xO0oCmIJeDGgaxild6aAr59k167zc50WLnnRKrT6bV
 8GCA==
X-Forwarded-Encrypted: i=1;
 AJvYcCUF+Btc07PsrjOkUxiPRPo03iC+op95iyexWDKmLNHimIclkhEYWsHxRvNGAH4cd0EWmYI=@dpdk.org
X-Gm-Message-State: AOJu0YyGQNTn7VrfAXrOH/TkbxJw69n5ligDQLZKamnbwdlNX0lWnRvd
 A3YTj57h1Uh6c84O1Tnvb7QAUnevsN7r9mYuP1fLgVYkDWesy9ei3o7V0xZb+Ye6oYzxKp7kz4E
 SIzjLVBVkbW4Ks4e5TJU42AsqL8IOeLJykOeHl5vcxS1bKbLpirCnQua2Otg9J2vNqPA6dtT8Y4
 ld7GjwOcm78pJRpb8=
X-Received: by 2002:a05:6512:b90:b0:539:93e8:7ed8 with SMTP id
 2adb3069b0e04-539a626a412mr2059843e87.15.1728043215762; 
 Fri, 04 Oct 2024 05:00:15 -0700 (PDT)
X-Google-Smtp-Source: AGHT+IFu4wKxLx5Ue7V2zRXxEhfR/Qdx+/UMQRJr1v2PnDU81+QTL6D0SCno4IbRlqWSEVN8LVvmd2tmUQNZ/AYO7Jc=
X-Received: by 2002:a05:6512:b90:b0:539:93e8:7ed8 with SMTP id
 2adb3069b0e04-539a626a412mr2059827e87.15.1728043215285; Fri, 04 Oct 2024
 05:00:15 -0700 (PDT)
MIME-Version: 1.0
References: <20240925194206.106825-1-wojciech.panfil@intel.com>
In-Reply-To: <20240925194206.106825-1-wojciech.panfil@intel.com>
From: David Marchand <david.marchand@redhat.com>
Date: Fri, 4 Oct 2024 14:00:04 +0200
Message-ID: <CAJFAV8x7Lk-XSuo6M1DDj8+DHAJ=Zaqs4GbEXQZcfF1+foA8zg@mail.gmail.com>
Subject: Re: [PATCH] eal/alarm_cancel: Fix thread starvation
To: Wojciech Panfil <wojciech.panfil@intel.com>
Cc: bruce.richardson@intel.com, pallavi.kadam@intel.com, dev@dpdk.org, 
 jacek.kalwas@intel.com, konrad.sztyber@intel.com, dmitry.kozliuk@gmail.com, 
 roretzla@linux.microsoft.com, Stephen Hemminger <stephen@networkplumber.org>
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

On Wed, Sep 25, 2024 at 9:34=E2=80=AFPM Wojciech Panfil
<wojciech.panfil@intel.com> wrote:
>
> Issue:
> Two threads:
>
> - A, executing rte_eal_alarm_cancel,
> - B, executing eal_alarm_callback.
>
> Such case can cause starvation of thread B. Please see that there is a
> small time window between lock and unlock in thread A, so thread B must
> be switched to within a very small time window, so that it can obtain
> the lock.
>
> Solution to this problem is use sched_yield(), which puts current thread
> (A) at the end of thread execution priority queue and allows thread B to
> execute.
>
> The issue can be observed e.g. on hot-pluggable device detach path.
> On such path, rte_alarm can used to check if DPDK has completed
> the detachment. Waiting for completion, rte_eal_alarm_cancel
> is called, while another thread periodically calls eal_alarm_callback
> causing the issue to occur.
>
> Signed-off-by: Wojciech Panfil <wojciech.panfil@intel.com>

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

Applied, thanks (and welcome) Wojciech.


--=20
David Marchand