Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp753963iog; Fri, 17 Jun 2022 12:51:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tqH8ja2RkH9sSBpQB+Iy3ldGSRRVjsAYWenqgWuGv5MyWsroTaCxetXxO33yoX6uR6lDka X-Received: by 2002:a17:902:c2d3:b0:168:e13c:4e23 with SMTP id c19-20020a170902c2d300b00168e13c4e23mr11221452pla.99.1655495482123; Fri, 17 Jun 2022 12:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655495482; cv=none; d=google.com; s=arc-20160816; b=pRd5og1ye3OFTygVNatRdnbf3keLX0vI93sYUDaqA26swlu9mVCCV5or1W2lWAosOo egri02i6VpPr25eVbIJXIbM6hQ3l0LT5RqeyhmheRzn/LKa2Hf9zgwSRNkAd+FTaNwhJ VeHcod0twTL+adzQ4pNEpNymvkus4WUMMOkGhhquceUUCFCM0fb140VQx62lAXEY82kq Gc8C313wwrXNlgymGtOBvpmTHyJExz0zBlOw8VZww4udpBm23P1R/qcKR12dFVJzKsuu B0X329vmvgmLp8h0Re1REfa51IL4TdemmvJEYmUDipRe/skw5CJPnWt4fxCntMKxNC8G a1Ug== 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=NQMHAwyimoB61nebQlVxpPs4wt6e0dms7bbM7wg+b94=; b=v1os6fNW9/XQDhYi7sSNK26ItqVUEifllzpORFW5XiOfF2EJXsxbr8tk4FosoN9TXL sV+87lWUz4rU8vWmiXtC5oREH9fzLw7MmO5dBIk9dRDhvL14ePGRRsYhc0/qcig3zoSF yGdlZscOKQvsa9lA2VNIleLOw+1bDN+jkN+BbDKXv6V10ldO+CHsmfkhQj6SLmNt0LsT tEgh5Mala6iul/9Clt/FoF8MZZt6ZNJCoEcoqQpnDYI/2vh0p4VANETmvUlBq9E00XgT V82ckZXaLs0EIWDtFV4SdBYJoUbeyFn1W2lRjUuwuCvBP6bHXEp1LjwU1IjgUW+wavSH QpZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eUoRJb6d; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ja12-20020a170902efcc00b001619ccff412si5754435plb.410.2022.06.17.12.51.10; Fri, 17 Jun 2022 12:51:22 -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=@google.com header.s=20210112 header.b=eUoRJb6d; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231811AbiFQTZa (ORCPT + 99 others); Fri, 17 Jun 2022 15:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbiFQTZ2 (ORCPT ); Fri, 17 Jun 2022 15:25:28 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9339E1CFE1 for ; Fri, 17 Jun 2022 12:25:27 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-3137316bb69so51227547b3.10 for ; Fri, 17 Jun 2022 12:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NQMHAwyimoB61nebQlVxpPs4wt6e0dms7bbM7wg+b94=; b=eUoRJb6d0zusXWkcQUyWO/SswYusNZWESJhnSpmi/+80sIw/By+fzNthm6cu1evOyp VJXsFHYL/drSHz98D1/t8LaIxkldrFE023gWiQexpHwAzrUyoPtcwL+vNWJ+SAADfKjo Bwq0SR5Hpc/WeE9GUSIeCH083JD0Ba4uE47yJdYBgKx5Obqo4MO2qdU2Xg4T8JmAwmly UXxYWqB1ZyPMf+/tRga0LeWt9xe/lIvmNpeSx0i9hYf6jW+EH/Yhl9laPgUXZ1EZAaXZ Zjv+tw2uTbptGFkIDgZwt5jKZMvRaJCq0BdD5MjkV5/PioJttlbZGu/6UEX6dKDd8Kk2 4pUA== 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=NQMHAwyimoB61nebQlVxpPs4wt6e0dms7bbM7wg+b94=; b=jk5NIoPOr09begw2pNIrZVyU81znaMutApDI4ceFyTn7yCA/3mlIcLQTHO0sjzgEEe F3xgaqHmtdnOp1U6mkyPVv7uGsDmssarTMivvy5fG74mCFKwlxrsb22K+OwNMQkwVtbg SSO/E0SlwOYy5u3tPwJgffi9hFmy+3ZGHKLDk76Wa9PlunEjsibwRHpxmne2MgKZgS2V E7nAzkHVEoArSlPmbpXiYk6cA0skfvMEhAen8foukXDJDqI3FOC1kD7mPfpBWGC1t3ix WMo6i4ORO252b6cC1HwqtcKALidweUMO1di0JDN1nN6u6pQSKgc/j81OjX1pwe4FPNFd Bmrw== X-Gm-Message-State: AJIora95qgypjyugJXAXXRdm6VchfxTVRHPyoiJao1gnKcNZeMFwId1H /69CKbVdlszpROdgkYeJc8KO2CrVvzEKd1Zcb9YigcoE07qTPg== X-Received: by 2002:a81:3a81:0:b0:317:7dcf:81d4 with SMTP id h123-20020a813a81000000b003177dcf81d4mr6319611ywa.47.1655493926519; Fri, 17 Jun 2022 12:25:26 -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: Eric Dumazet Date: Fri, 17 Jun 2022 21:25:15 +0200 Message-ID: Subject: Re: [PATCH] locking/rwlocks: do not starve writers To: Linus Torvalds 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=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 9:19 PM Linus Torvalds wrote: > > 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). Interesting... I think getrusage(RUSAGE_SELF) is blocking interrupts in the possible long loop: do { accumulate_thread_rusage(t, r); } while_each_thread(p, t); > > I suspect eventpoll just did the wrong thing. > > Linus