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 E2983A0A02; Thu, 14 Jan 2021 17:56:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D009C1413C5; Thu, 14 Jan 2021 17:56:04 +0100 (CET) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mails.dpdk.org (Postfix) with ESMTP id 122B014137C for ; Thu, 14 Jan 2021 17:56:03 +0100 (CET) Received: by mail-pf1-f177.google.com with SMTP id h10so3691081pfo.9 for ; Thu, 14 Jan 2021 08:56:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oGl6cm28BhyMLoAUyaZo4edPDZHcTC6yzmy2cMjR97k=; b=1r5OGY6HSf/WbxLDH9mPJCSpBbMsVKMxBGC9bYxAwbKDBxub8tKcZfoV/vs0kiy7YK EbT1r5Df46iz7Gj904tKfPyIp2absve4KLE1btfTH+JPUW4XEVTwzwGirXnrmtVFJWxP tLToi7Yj2cgYSFMxvdf3IxpfjYR9ZCVGrpSpj0q78no5PB5wTrjsRbVDWxNKL2OvGuiZ Q1Yk0KktGSocCXszQ1Hee41wOLBmOSrobOW2tI4xIqWDP06DIRhetpVhfIyxgwPMAuen df1HvJPW9jRECI5zbod8f9lxyLITpNxdRr0Q5BR3fKYHc10HmsFy3aUJHOH112L9luan 2kcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oGl6cm28BhyMLoAUyaZo4edPDZHcTC6yzmy2cMjR97k=; b=MjHxoPd8Z7pvi6JxnMYtRiOVxpgXkAqz/DHHCmlkvznJB1DGbqqAnVbes34/wOsdzE sUZDJkkncZ8WhROhGPwz9lT5D3taBzGMPwu4zX2OpRBaSZkcYmG90jdW76EDmCawHwvs bXnZcRaETnhkantWXlucTp8CNs5U5/YMhcFljzuR5GD6jXc78r9mJzvvCE42qSAcHPft up9sIOjqjZ8zq5iJbK1QUU8aPObC7g6vCTiH1KUIE2Z9LKDs9tGad8rdeaZTT5gGYUsA SLIeta7xxMWUCpSbjpS+5ri/9brXFi+f9KEbrn7PMTMOEuCgY5yJpWsNZsS47z4WSi/k Pu4w== X-Gm-Message-State: AOAM531of/+DdgBO1b1Nl22tuYgimVsZxaqZ4jpGpoQ+VYp34jGBZzF+ SE9Uhyxcwv0Is6zaRB19FGPq0SxmwgeC7w== X-Google-Smtp-Source: ABdhPJyuHuvbqqxcAe6q66idloZos3lic07M+It0Xmeu4yxeyLQToeAM85zu7i5Uhv1w/GMhkPVXnA== X-Received: by 2002:a63:3e8f:: with SMTP id l137mr8294461pga.117.1610643361732; Thu, 14 Jan 2021 08:56:01 -0800 (PST) Received: from hermes.wavecable.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id k7sm5662860pfh.201.2021.01.14.08.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 08:56:00 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 14 Jan 2021 08:55:56 -0800 Message-Id: <20210114165556.31353-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210112010453.260646-1-stephen@networkplumber.org> References: <20210112010453.260646-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] eal/rwlock: add note about writer starvation 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 Sender: "dev" The implementation of reader/writer locks in DPDK (from first release) is simple and fast. But it can lead to writer starvation issues. It is not easy to fix this without changing ABI and potentially breaking customer applications that are expect the unfair behavior. The wikipedia page on reader-writer problem has a similar example which summarizes the problem pretty well. Signed-off-by: Stephen Hemminger --- v2 - fix wording and spelling lib/librte_eal/include/generic/rte_rwlock.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/librte_eal/include/generic/rte_rwlock.h b/lib/librte_eal/include/generic/rte_rwlock.h index da9bc3e9c0e2..15980e2d93e5 100644 --- a/lib/librte_eal/include/generic/rte_rwlock.h +++ b/lib/librte_eal/include/generic/rte_rwlock.h @@ -15,6 +15,12 @@ * one writer. All readers are blocked until the writer is finished * writing. * + * Note: This version of reader/writer locks is not fair because + * readers do not block for pending writers. A stream of readers can + * subsequently lock out all potential writers and starve them. + * This is because after the first reader locks the resource, + * no writer can lock it. The writer will only be able to get the lock + * when it will only be released by the last reader. */ #ifdef __cplusplus -- 2.29.2