Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp738162iog; Fri, 17 Jun 2022 12:29:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v1mHlggPisY6TFJEpEsSMICyPihRh3DtSBBWT6oxG+NGIgvf7ah3yGT1PsDi+tv2Fq1QXx X-Received: by 2002:a17:906:728a:b0:715:2fb5:19f9 with SMTP id b10-20020a170906728a00b007152fb519f9mr10381497ejl.170.1655494146077; Fri, 17 Jun 2022 12:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655494146; cv=none; d=google.com; s=arc-20160816; b=y1cjRATDOhZ51Lrrw7waTKVGHNYNS5e6XPGdJMirZFU8E8FLidNzbiu3NLBU79Gb6B XqOI8vdfJLnplyqvZ25thtaADelA2RhrlmeQPjMEVF2GFLfs8rQG07fyInklEKtnImCe l9UvgGgLjjC3ASpkzn/Gq8o2lkK3Q1HOpmLTld3eIdRQOoN0r9HwpYwV+U4JKkRVxnwi sueTJNt9OqxCf4JC6XBJI27CqZo/+RLYaOEnsS2J9pGL3dMxZp4kr9O5HGbsNzZvBSCM oW/5wG7vQ34SpNPB0PXdoxVV8mJF7c8IxzwqNGiRZFPo7u0uXw2eyMIF92Eq1wffbaaV U/uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DI1RxyMzElXtlcQrNQZug30SgE2uSFwxG1kHH+iR6eM=; b=cyBRL3Pg6QzHokVjBTU2a2WcmJEPohGJSqEuXx1WlRKJrB9dF1aUDvJRvRlKwBjtGO L7qmNFn5CfBgu5YD0rYp72PrnSc+Isk88FxyF6OeCpSo2VKF9sELyWPJWkD6z3YldfpM 7RlCpOkrPfTlRIYPlHO+r5KOIJul5/M8Taluk5Ku3EGKutqelL9TPVS45d0NsVSu2fXf 8yGkD8N2ENHS1C5GS+bwd8h5mn98oqD0XTxB42eRYCO01Cj6GCM/Ay2CNBeVl9caKkia QnEFddENZ1pL87Ycq17HxwiFVgHzpChyFXyAEWsJOZRJwtciXu3oGTIWAFlaBFdbb6yb MDWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=OZMdtgld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho13-20020a1709070e8d00b00718e7d37346si6675717ejc.978.2022.06.17.12.28.40; Fri, 17 Jun 2022 12:29:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=OZMdtgld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230259AbiFQTTz (ORCPT + 99 others); Fri, 17 Jun 2022 15:19:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbiFQTTx (ORCPT ); Fri, 17 Jun 2022 15:19:53 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F73A34642 for ; Fri, 17 Jun 2022 12:19:51 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id ej4so3437560edb.7 for ; Fri, 17 Jun 2022 12:19:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DI1RxyMzElXtlcQrNQZug30SgE2uSFwxG1kHH+iR6eM=; b=OZMdtgldn2H7V3EtlQ5+jBb7O1GqZR6ZtJXHPkuqA2kIoPKyFiMkzZvQ31Bnq4pQii HnoV3nD8jo9ufRDwBXvwpAw75D+Tsne78FPMg8gEP+jrgUZ1k8g1sEu8+vVSPjwhn6iF zIy93qLf+DfBMXjP6Vs/ehN6+BnkJSdbH0ZCs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DI1RxyMzElXtlcQrNQZug30SgE2uSFwxG1kHH+iR6eM=; b=tppv99ytj+EZxYrNl4hVJaNIy81TN/yceJgqFGtXDo9gvCztbnnk4X9N4ozl8sdt4e y1U2M3eBT5/XROdJCUQkv7zCYvjz7Ox/Uuaujh2fveiCQ56CtwLL0wApIYMP8HYbGlVA gXhthcP3hf1+9nQACJAf2KouQ2hKB7KshhE9PwjGUCyVE5OTXS4juzavxXP9XuLXfHTI OkaoWpzYlePDOeFOUDX1kCVSYFiRI4b65EaeBVIs79wMlijb1xd0C8r6Rga/ntUrozPz toOAJ8OExl+xwUmCko/0qZeoE6oy08gPeZoUCUUR9BLQS7MTYwNIBFoAqc8r5P1pTTjB 1Xlg== X-Gm-Message-State: AJIora/7CiqtuWzuc0/wPkwsfZ3rU3bA7MhKaFCm9ELV+zYeQC7vzqv0 ywNh1XgF9y9vobDVtI58+qeuwkqQ4b2JHw/g X-Received: by 2002:a05:6402:42d5:b0:433:1727:b31c with SMTP id i21-20020a05640242d500b004331727b31cmr14176207edc.9.1655493589781; Fri, 17 Jun 2022 12:19:49 -0700 (PDT) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com. [209.85.221.41]) by smtp.gmail.com with ESMTPSA id r26-20020a056402035a00b00435201d96f8sm4260036edw.16.2022.06.17.12.19.49 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jun 2022 12:19:49 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id q9so6884818wrd.8 for ; Fri, 17 Jun 2022 12:19:49 -0700 (PDT) X-Received: by 2002:a05:6000:1251:b0:21a:efae:6cbe with SMTP id j17-20020a056000125100b0021aefae6cbemr4117896wrx.281.1655493588814; Fri, 17 Jun 2022 12:19:48 -0700 (PDT) MIME-Version: 1.0 References: <20220617091039.2257083-1-eric.dumazet@gmail.com> <2dd754f9-3a79-ed17-e423-6b411c3afb69@redhat.com> <2730b855-8f99-5a9e-707e-697d3bd9811d@redhat.com> <7499dd05-30d1-669c-66b4-5cb06452b476@redhat.com> In-Reply-To: From: Linus Torvalds Date: Fri, 17 Jun 2022 14:19:32 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] locking/rwlocks: do not starve writers To: Eric Dumazet Cc: Peter Zijlstra , Waiman Long , Shakeel Butt , Eric Dumazet , linux-kernel , Ingo Molnar , Boqun Feng , Will Deacon , Roman Penyaev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 17, 2022 at 2:10 PM Eric Dumazet wrote: > > So I wonder why we replaced eventpoll spinlock with an rwlock. Yeah, usually we've actually gone the other way. Spinning rwlocks are seldom a big win, unless you can get some secondary indirect win out of them. That secondary win is often: (a) unfairness is usually very good for throughput (iow, the very unfairness that you hit may *be* the reason why it looked good in some benchmark, and people decided "ok, let's do this"). (b) the special case of "interrupts take the lock for reading only" thing that allows other readers to not disable interrupts IOW, the win of a spinning rwlock is not necessarily the "we allow multiple concurrent readers" that you'd expect, because if you have small sections of code you protect, that just isn't a big deal, and the costs are in the lock bouncing etc. It's also worth pointing out that rwlocks are only unfair *if* they hit that "reader from (soft)interrupt" case. Which means that such cases *really* had better either have very very short locked regions (with interrupts disabled), or they really need that (b) part above. And yes, the tasklist lock really needs the (b) part above. Disabling interrupts for task traversal would be completely and entirely unacceptable, because the traversal can actually be fairly expensive (lots and lots of threads). I suspect eventpoll just did the wrong thing. Linus