From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E0011459CE; Wed, 18 Sep 2024 18:06:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A811242EC0; Wed, 18 Sep 2024 18:06:14 +0200 (CEST) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by mails.dpdk.org (Postfix) with ESMTP id 7A7DB42E99 for ; Wed, 18 Sep 2024 18:06:13 +0200 (CEST) Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-7cd8803fe0aso5118069a12.0 for ; Wed, 18 Sep 2024 09:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1726675572; x=1727280372; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=D/ECMoBgbEL+xsYUpaf6sAzvnsgxyuzT5C9XHkwgilI=; b=EpghVEj5lskNCfuYNBVRnn0kxGNtdmCdAuVHdmh2x5eIx4e9asroUkiNaAfA102sEA uSNIjFCpAMw0t/uT5DQjlj13C3XBPdbS0cXPBffMrNOW1X1UiYDgTDMRIi74pSZv846a UqB83Sb1I17DnSzD9GM9e7948Ojbw2/wDqGSr5zG1mIgtfBce8NXLSTX+x9yhCtiU/MQ sV8RsVZ3q3Iwckz19tEWGBkMXpjc0VQEdUzM0ogKeCtlfaGjvTRVqHt7SCh/QkjTxriS iO1kyqqbbYzRXkoNCzXNqEFDVWrFgKtyb4JdvRfdo5ZTc4BaDJaE5VTnzemtE0TbSgGL UQyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726675572; x=1727280372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D/ECMoBgbEL+xsYUpaf6sAzvnsgxyuzT5C9XHkwgilI=; b=RGdkNn57uynQqPtXMyfae7y2EWaZsWlUJ2r9xdbevekhl4TY13w8ke+LR1SmWfP2Jz MgUaoK4g4ix6HPnwpSIzCUvaraqGAIDa3m8rfm4P6GEvfkh7wgMU81RqwT8o8p3Tped4 93XJhJkE+9uuBIUhRaIETiIMV1eEB8pjkCvfzwGHQvx8SLFsCG2Ewofd37EvYRN4YQ3L ZWOSes2yLtzsl3ZUHILPKPKu5K2oowVEkmktC+2fUB6rQBiUuo+fhasdj4Hvz5zYmwEi hB7ja1ii7/lsSjvdvRzRGx7D7JpsKn95ZGyWmgZ1Kn6jOMPAIdCF7I1hV24OssNdsUSy nurQ== X-Forwarded-Encrypted: i=1; AJvYcCU+3r9MbgixvtTLtmBeOtiHkvvDoIwstg2oklRj2m8BRi6wIH4d1s4d9jED1UlYczQJZ70=@dpdk.org X-Gm-Message-State: AOJu0YzldEGy1R9y+H32viwkMwYYLul9TrXO28QjFOCgGtHryOSaMqL5 r7TUTZDPiYlB/hP2eaXSWeVwz9UuzQ8iF0wvtYy3/++GMCuN3EOi5tUCBocrvMVD3ITJCCesYnJ i X-Google-Smtp-Source: AGHT+IGv/FBE6dfATCgQRB1aay/p2WaVOCrozWQEwz2hBUDdUaYZ62Yp9ilwGEw1Ln3tghvUclrawg== X-Received: by 2002:a17:90a:8584:b0:2d8:b923:b56a with SMTP id 98e67ed59e1d1-2dba00822c3mr21966767a91.41.1726675572426; Wed, 18 Sep 2024 09:06:12 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dd608d1939sm1831637a91.33.2024.09.18.09.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2024 09:06:12 -0700 (PDT) Date: Wed, 18 Sep 2024 09:06:10 -0700 From: Stephen Hemminger To: Wojciech Panfil Cc: , , , , , , Subject: Re: [PATCH] eal/alarm_cancel: Fix thread starvation Message-ID: <20240918090610.1dcfb37c@hermes.local> In-Reply-To: <20240918113906.64350-1-wojciech.panfil@intel.com> References: <20240918113906.64350-1-wojciech.panfil@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, 18 Sep 2024 13:39:06 +0200 Wojciech Panfil 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 Make sense. Alarm is non-EAL thread, and so is hotplug. Acked-by: Stephen Hemminger Does the timer_stop code have similar issues? Probably only if users do unexpected things like map multiple logical lcores to same CPU.