Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2600071rwb; Fri, 16 Dec 2022 04:22:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf70PnCZSwmyshgTA8uyKRuUKn14KixrOxQB+gSFPSKrTM/XYZgkEg+pb+RBxu/7JgXcYhKP X-Received: by 2002:a05:6402:2b8c:b0:461:2288:6804 with SMTP id fj12-20020a0564022b8c00b0046122886804mr26220867edb.30.1671193326110; Fri, 16 Dec 2022 04:22:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671193326; cv=none; d=google.com; s=arc-20160816; b=wsnpQKcjcj6hbhfTjH/aOcOoN4aPQHqOfOSQYJSLU74amo+AbvIpdW+xsgp74IZZNe QTDmI58lGWQbv7ZIywiMu5o0lRWmiwmjmkvUA7mov9lNdwJo36+nKxzwf9rsxtvjLWZu 8ZrED1KtL1hqCklKdXY/p1YdAnCeYGM+Nyfyc0735AcNHMZgdKOrc5wq2taL3BazCOan sWNF7weBcW0tQTCWoLCfSP8WR1Y2fw2H9eDKEICe1JAifkvoJrurzKMUEU5JNwoWtqxu 7K+0iqWg/wIQ9yULK8emUbNi9F79bCqUU4S8G8zNvNzN+ROUKZtmzbuMnFaL3sJvtuwS 2Nig== 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=a7C4DlTIJe/XAzDTApvBRiD8XTjnKR9AH5A3VoUGLOg=; b=YAWYQ9JyBaxLZ9T5UfOJEPX9UF9NpmccQ1MCC44kZkdiWeyfdeiAlMLiNSQ20+bFLb 9vnY8ZBR02p4uJgh6QKcgGNfIhs8mkaFieFbi6m8MCr4PNvxayPVoWfyQ81v3wNjbVoK ocovC38AOX/AUfiZJm6P/7lUFwOWzdaB4iduTDTk5HMmsdnq4coLMh00fy3McXS/QalF 22Zw+Pt6fFRDF7UAfoUr7OHTbnBocT6Zk2XKWHgiG1PhZ2OSBpxr3lPFh93ezy1PAstZ nvc9nkx/y26VfQgi3/q2tXH2C+BKEAiDFxFb1sPI+ELb1GXWJdaQfR5weDhJrh3tsSIn jbwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=NwQY0lOy; 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 f13-20020a056402068d00b0047338d1bfcfsi2207117edy.166.2022.12.16.04.21.49; Fri, 16 Dec 2022 04:22:06 -0800 (PST) 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=NwQY0lOy; 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 S230331AbiLPL0n (ORCPT + 68 others); Fri, 16 Dec 2022 06:26:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiLPL0l (ORCPT ); Fri, 16 Dec 2022 06:26:41 -0500 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BEF3286DB for ; Fri, 16 Dec 2022 03:26:40 -0800 (PST) Received: by mail-qv1-xf36.google.com with SMTP id pp21so1448214qvb.5 for ; Fri, 16 Dec 2022 03:26:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=a7C4DlTIJe/XAzDTApvBRiD8XTjnKR9AH5A3VoUGLOg=; b=NwQY0lOyux8zQdS9zMAo0gTIVBQw4Tpq5Bt9XfwxOWeeZoExJwK4JnJSNs6XbHTM+i Lv5bhR0Bu8KLvRSNai/hEYLSdT1W9Ro3qa4We7yN3/PP2J3AnHLZ4Lfu7LFF67Lx8MY2 w+h/UW7V9V8UrlOYYhT/brFKFpP4g/HD7/LKY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a7C4DlTIJe/XAzDTApvBRiD8XTjnKR9AH5A3VoUGLOg=; b=wvM7hXYqFkchVizh9xqCwBAFkZ1uHjLUuSeUuZhYFiQbiccMxqa0DnCHtnaRO6xAey aZPOCFBD6c7MLkJgqlqVg+7+hBbjQsnucedV619ZP/v8AZ3pKMlsNjX+Ri4o/vJY+kD+ HCNXohRomLtGkVzefu4EPhiLJ6M4BmgHHaLD0O4s4ANjFhd2wG4FItxjlMW94yU5Vy5U 9ZQFRX8i/+MBiSgsSo9ewlyF7e8Dog69bHW1U/zIB52JmiuYQAIw+87OHtDEpImTev1i OIY097jW0GQ7tCG7E3YmjC3tWixOfeqURoO2O/N7rHRBphBfm965QsHPSm/C6h/MAaEJ PzhQ== X-Gm-Message-State: ANoB5pl5bceg6+TWKOsCGHPzQM78SJWud9zaWd00PB9mxCQ4pXcOi0JH HUDNFKtvMx6xSfTUY/F05W+sdvVE0kl1HeAE X-Received: by 2002:a0c:e785:0:b0:4c7:911:274f with SMTP id x5-20020a0ce785000000b004c70911274fmr46719312qvn.35.1671189998966; Fri, 16 Dec 2022 03:26:38 -0800 (PST) Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com. [209.85.160.177]) by smtp.gmail.com with ESMTPSA id 195-20020a370ccc000000b006eee3a09ff3sm1263853qkm.69.2022.12.16.03.26.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Dec 2022 03:26:37 -0800 (PST) Received: by mail-qt1-f177.google.com with SMTP id ay32so2379697qtb.11 for ; Fri, 16 Dec 2022 03:26:37 -0800 (PST) X-Received: by 2002:ac8:4992:0:b0:3a7:648d:23d4 with SMTP id f18-20020ac84992000000b003a7648d23d4mr19675311qtq.180.1671189997363; Fri, 16 Dec 2022 03:26:37 -0800 (PST) MIME-Version: 1.0 References: <5eff70b8-04fc-ee87-973a-2099a65f6e29@opensource.wdc.com> <80dc24c5-2c4c-b8da-5017-31aae65a4dfa@opensource.wdc.com> In-Reply-To: From: Linus Torvalds Date: Fri, 16 Dec 2022 03:26:21 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: possible deadlock in __ata_sff_interrupt To: Al Viro Cc: Damien Le Moal , Wei Chen , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, syzbot , linux-fsdevel , Chuck Lever , Jeff Layton , Peter Zijlstra 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 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 Thu, Dec 15, 2022 at 7:41 PM Al Viro wrote: > > CPU1: ptrace(2) > ptrace_check_attach() > read_lock(&tasklist_lock); > > CPU2: setpgid(2) > write_lock_irq(&tasklist_lock); > spins > > CPU1: takes an interrupt that would call kill_fasync(). grep and the > first instance of kill_fasync() is in hpet_interrupt() - it's not > something exotic. IRQs disabled on CPU2 won't stop it. > kill_fasync(..., SIGIO, ...) > kill_fasync_rcu() > read_lock_irqsave(&fa->fa_lock, flags); > send_sigio() > read_lock_irqsave(&fown->lock, flags); > read_lock(&tasklist_lock); > > ... and CPU1 spins as well. Nope. See kernel/locking/qrwlock.c: /* * Readers come here when they cannot get the lock without waiting */ if (unlikely(in_interrupt())) { /* * Readers in interrupt context will get the lock immediately * if the writer is just waiting (not holding the lock yet), * so spin with ACQUIRE semantics until the lock is available * without waiting in the queue. */ atomic_cond_read_acquire(&lock->cnts, !(VAL & _QW_LOCKED)); return; } and that's the new "civilized" reader unfairness. The traditional rwlock was unconditionally unfair to writers, to the point that there were starvation issues because new readers would always get the lock. Linus