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 3605745A50; Sat, 28 Sep 2024 18:40:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DC6CB4027A; Sat, 28 Sep 2024 18:40:57 +0200 (CEST) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by mails.dpdk.org (Postfix) with ESMTP id 3E3CA40273 for ; Sat, 28 Sep 2024 18:40:56 +0200 (CEST) Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71b070ff24dso2738581b3a.2 for ; Sat, 28 Sep 2024 09:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727541655; x=1728146455; 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=RePlCrB1a3tf+mchQMpfNC3AKpXypxHvelZeGrg42rg=; b=ecTPjniexGxPyHSqoVfkH1CNJmsW9ojDh5YM5FdIkQjHtg9o/t0Gn/7/BLeIOOnRnm VKwvfP73HgMXGfxtHzG9GstNpXzt7GjNFZK0wyA/gJFbz+H/2hWB0FMs3oYw3FNm7auc orVqYsr+NlCWns9C6IkdFiOihgc5Y8A07YQGYs467sNIN4hbxaK0dvBar5ZGuwPYPNfZ U0AaihgwLnMNvkkdxF36UzqoxCt+f/ItrKLJoDabxG0GkHWpkf4JVSEE5OnFMYSobSew 590K9Tbgj7BPYhHusYwm5pRn+p9UPJ6zGCeS05LQ3r53UJLzgtCYb8nWO/4JbhX4b02h +ppQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727541655; x=1728146455; 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=RePlCrB1a3tf+mchQMpfNC3AKpXypxHvelZeGrg42rg=; b=GvMYorga5hVNMi1WUkxMNLvg2J2LOVhLx+gRCB9KlVAONEZiBlpPghuB5OOBX1lcwU w9ktBVtxahKHx07Kb1Y6QZ590D3qer7N4JspmJXypyryis5zaVtq+JomsviVaT5mukW1 6CMe0xMQJG0D4fPxKJBuxe4kYQnKWp1dILq5JVWaaxFEN7MCXVYrqbJZXDAqrMzSIDjz ictwn7lkysPMMF6BIeRu+0AuZNqFEaE0RyrUCQQaXZ0VNPpZGLlXpTb9gpgKk+5/WYjV W6MqgE0UHe9ji+QRX1bMP22wCi27da+0x6ZscoHxHGYtpCWxIDT/LrSicE0Tb61PhyBP cWEQ== X-Forwarded-Encrypted: i=1; AJvYcCVtwaD+2ncnCfgMpVCYN5w6c/fQDFT1Nv+OoJwkoy5Romhko1nBOK1VQEZvEc3pNQnRgxw=@dpdk.org X-Gm-Message-State: AOJu0YxaQqUgFdgY3MyisiHt2qmCcw6c14UXMiWrRdG7JIjME4MM1WBo uKBdLuvBgJsPwnWbF0Ha+hDmJX/6sGIqbv1Czb5YBDCMsLKkSyIexfnkJtnmzqo= X-Google-Smtp-Source: AGHT+IHhWQL8fOk3w7mzlTWYDdVxhJGikAfTpYKP6WxYOJK9OaBipfn6TRHxZxC0h9qCKK4RkBXxcg== X-Received: by 2002:a05:6a00:3d12:b0:719:2046:5d4f with SMTP id d2e1a72fcca58-71b2607888dmr10918903b3a.24.1727541655093; Sat, 28 Sep 2024 09:40:55 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b26517bcesm3421606b3a.99.2024.09.28.09.40.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:40:54 -0700 (PDT) Date: Sat, 28 Sep 2024 09:40:53 -0700 From: Stephen Hemminger To: Wojciech Panfil Cc: , , , , , , Subject: Re: [PATCH] eal/alarm_cancel: Fix thread starvation Message-ID: <20240928094053.47f3c72c@hermes.local> In-Reply-To: <20240925194206.106825-1-wojciech.panfil@intel.com> References: <20240925194206.106825-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, 25 Sep 2024 21:42: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 It would be good to get test for this in the DPDK functional test. See: https://patchwork.dpdk.org/project/dpdk/patch/20240809152540.9568-4-stephen@networkplumber.org/ Reviewed-by: Stephen Hemminger