Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp89456imm; Tue, 22 May 2018 14:33:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq75rDnMZNhDE/XjTVt8iAeQ57mXSNXww/RyDtHLPqQrib95QphJTWyALlLXuoPtnEW2lNz X-Received: by 2002:a17:902:aa4b:: with SMTP id c11-v6mr155332plr.17.1527024793674; Tue, 22 May 2018 14:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527024793; cv=none; d=google.com; s=arc-20160816; b=SIg6XG5nV0+DOVTPb+1m/aDKcnUN3R4g2Oe8Qj9c1EiblI/eNHwaflpf7kLQQ6EwVm QfYk3JZwarOF1rWJ/fJeMMyr55FjXT/cs/CWqxh7cs0sQUViga+knul47Cx8ZCgGNfKk VKAsVPfmZTPNU7W1Hq62Zd6tg8U3zkWZ4c3Z5n7BCJ255XNgCxeGXatjq9LUcHSO1oUA TEPBDFbQfz/S9MmxjWod5ISpi4niGlPfgofCu9Kpn2TKFjJmhENOlixmGk6X7+wH8bBr dQLwZvFXlg9A31qzTXr3lLjAmt6cPGfMjtZ06qCNaPc/FjMqsXmHU0kmQlaZpU+y3xKv jt/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=O/gEasU1PLFDzCoPau9NGOkOhRv3n6Wo7ZLclJzUB7o=; b=UMwaLXBbYJZcGfxQAaeC6yg6uTmVOiaoH4s27zsOnaBc+vamUIPDbCwTRwhAg6XKu3 jfQMSBY4rLpQWUr2QyHFQ28cYEAUNTAAz7wvUqAZUJOQsanUUHWRHSPauYLvHAnrMbV8 N8HCawn676m1Hu8I5tBVg8qbsX87dVNQLPa83I672BzS98oqslZ73Rl2G9FDdEpNKy5p szpEckAB42hSGtvzWEjSwir3L8o31yKCTqO3lV4t/39pqFxJtRJyCA2w9SCcE1Fp+lY2 N3nD/be3jSMq8dMmwAbhcW/CVxSGxjEgdwcIuf5S8h7d8oxPUBfBVTV8iZu3TluZ8U52 BZKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=RMzQjCam; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1-v6si16926076plb.558.2018.05.22.14.32.59; Tue, 22 May 2018 14:33:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=RMzQjCam; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753174AbeEVVb5 (ORCPT + 99 others); Tue, 22 May 2018 17:31:57 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:55187 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753017AbeEVVby (ORCPT ); Tue, 22 May 2018 17:31:54 -0400 Received: by mail-it0-f66.google.com with SMTP id z6-v6so1805952iti.4 for ; Tue, 22 May 2018 14:31:54 -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=O/gEasU1PLFDzCoPau9NGOkOhRv3n6Wo7ZLclJzUB7o=; b=RMzQjCamzox/c1dq6M8xyak24HHOMDmPm/X61d7s+1h5V2udi6eIrBf6PTa+2sBfKA e5ph9ktGpN8sUaeI8Jy+2TVBg+jJUEoMsJxYkUn55XImcVvlGSKuda7bWwMMjtwOjpXa JwcdP0ce4XWcqlE5xL/TlBVGrLvsXt64Fd9Vg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O/gEasU1PLFDzCoPau9NGOkOhRv3n6Wo7ZLclJzUB7o=; b=qZEcC5jw3lqeM0HDg2vUFT+XSObmDDSFBbwWKUHvFPNiUHuo2dUN+jI2Y30qPkVNUc 9u/aK/6l3Vty++xhczcMp1mrPaXCRdUQWWhPv6Hb6rpepT77yjMI627MlJdJ6kiwfENc sz6N6T8V9hMCwW4wJMzrm+8cCg4sjUIR7fJ8hbA4pLc72XfMu2r1wEeTUN1Sh4yRg9k/ NEpxfoeSmV1+okQ/O/RoyhORKhcD4zlwqyi98j6vudhfr+/igPe4mm1uafAZKq3CkKoL JEWtV/BD2q7MVyKFKRzDaTIA8ONGFVTI9PwYkwjBGNjTyoWQyC0xkPHr6CiGpU4DWUtC kUDA== X-Gm-Message-State: ALKqPweLK0gEeT6waynvyfzynvTjCmU3kfKIxMt1X7CDcxRSMANSJs+G 9jFC9kcB8GA+qr8gExh0nCG+QV4LYWfp/xHy580= X-Received: by 2002:a24:2213:: with SMTP id o19-v6mr2844228ito.16.1527024713595; Tue, 22 May 2018 14:31:53 -0700 (PDT) MIME-Version: 1.0 References: <0879f797135033e05e8e9166a3c85628@codeaurora.org> <20180522211724.GR12217@hirez.programming.kicks-ass.net> In-Reply-To: <20180522211724.GR12217@hirez.programming.kicks-ass.net> From: Linus Torvalds Date: Tue, 22 May 2018 14:31:42 -0700 Message-ID: Subject: Re: write_lock_irq(&tasklist_lock) To: Peter Zijlstra Cc: psodagud@codeaurora.org, Kees Cook , Andy Lutomirski , Will Drewry , Andrew Morton , Rik van Riel , Thomas Gleixner , Ingo Molnar , Eric Biggers , Frederic Weisbecker , sherryy@android.com, Vegard Nossum , Christoph Lameter , Andrea Arcangeli , Sasha Levin , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 22, 2018 at 2:17 PM Peter Zijlstra wrote: > qrwlock is a fair lock and should not exhibit writer starvation. We actually have a special rule to make it *not* be fair, in that interrupts are allowed to take the read lock if there are readers - even if there are waiting writers. I'm not sure how much of an fairness effect this has, but it's required because of our rule that you can take it for reading without disabling interrupts. See void queued_read_lock_slowpath(struct qrwlock *lock) in kernel/locking/qrwlock.c. > You basically want to spin-wait with interrupts enabled, right? That was the intent of my (untested) pseudo-code. It should work fine. Note that I used write_trylock() only, so there is no queueing (which also implies no fairness). I'm not saying it's a _good_ idea. I'm saying it might work if all you worry about is the irq-disabled part. Linus