Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16136365rwd; Mon, 26 Jun 2023 06:17:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4hxePAzSiWgvhWM6Wq25zFrWaT3Vig6RL9Rk6mDshLmkR5YwdFHc8//KohDEFLEtcwuWh9 X-Received: by 2002:a05:6a00:b8f:b0:666:5fc4:36b1 with SMTP id g15-20020a056a000b8f00b006665fc436b1mr22866389pfj.26.1687785448485; Mon, 26 Jun 2023 06:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687785448; cv=none; d=google.com; s=arc-20160816; b=a3h04Org8YumSanOj7KEMcSwxyrNvuzW2kXSjSFza8H3AntDg9TDU5ka6cbUBMnE71 H5RyhMM9mJ9PfbVXq19JCfH6SEy6x4V/9Who7wV6mudvixJ2M5ApF9205o+kU2i4Q8U6 FUMczyEPT5Z57Z5dgwj3N3d+Dky+Q+YAxCzKBeIzIbw3Zh3MBrO72m7Cp+sA2r4Hi5Nr noRpybaunL9cV9ox1lK9VlQNK/pXM4lmCvvb+NCcYiiksMleevBHzWZmNjwqOC/IyROX fAzVQ9u/IITrzGML+n5ytKZCuL/gzQrDEcuSKLldB3X97bv4nFXYLD2x4lI7TLDFIKkM ULxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=2M8s+AXPxv/gB+GT8A7is8erJy7g4n9MFs2gGfoPyhg=; fh=9ezz4HIf1BWKIELTVdcyzenEaKOkSMWrHRhT08obJ7g=; b=aDc1OQrf7w5AAqJ+k0xljTAqTku4EwFpLfi3MKoJfTgNyvdNAW509s39vVdCIfkqeC 5yc+FFt8MUqc5CS8MHIl3dHFI4HkU5mxV4e6mq8n9mh3zZsQaVnJAYOjtsNuC+V6BRZf +KcETZMrUikeK6Tc68VFCigMNSMktOGdFU9oK6CflIOEfWti3+mPlFmDrA8Q5cUomRbP hU59AoDgedCCu7kwnBoYNMSVLlsxenZjsOw+HjwRkQKmUlVE5KIWR0bfszTgqHk/FLkY 53tcQ7+tzMiprUhG+jAVshPVKY2yQ3y4DRvCSSHrbMTB4UaQ8/8CM1IZZ1KHE/4qgHF2 3jig== ARC-Authentication-Results: i=1; mx.google.com; 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 v1-20020a634641000000b0054fd473b82fsi3707895pgk.260.2023.06.26.06.17.03; Mon, 26 Jun 2023 06:17:28 -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; 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 S229851AbjFZM42 (ORCPT + 99 others); Mon, 26 Jun 2023 08:56:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjFZM40 (ORCPT ); Mon, 26 Jun 2023 08:56:26 -0400 Received: from outbound-smtp11.blacknight.com (outbound-smtp11.blacknight.com [46.22.139.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87F6C121 for ; Mon, 26 Jun 2023 05:56:23 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp11.blacknight.com (Postfix) with ESMTPS id 48CEE1C3E9A for ; Mon, 26 Jun 2023 13:56:21 +0100 (IST) Received: (qmail 26177 invoked from network); 26 Jun 2023 12:56:21 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.21.103]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 26 Jun 2023 12:56:20 -0000 Date: Mon, 26 Jun 2023 13:56:18 +0100 From: Mel Gorman To: Sebastian Andrzej Siewior Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Luis Claudio R. Goncalves" , Andrew Morton , Boqun Feng , Ingo Molnar , John Ogness , Michal Hocko , Peter Zijlstra , Petr Mladek , Tetsuo Handa , Thomas Gleixner , Waiman Long , Will Deacon Subject: Re: [PATCH v2 1/2] seqlock: Do the lockdep annotation before locking in do_write_seqcount_begin_nested() Message-ID: <20230626125618.e52lrsmulrubrftm@techsingularity.net> References: <20230623171232.892937-1-bigeasy@linutronix.de> <20230623171232.892937-2-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20230623171232.892937-2-bigeasy@linutronix.de> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 23, 2023 at 07:12:31PM +0200, Sebastian Andrzej Siewior wrote: > It was brought up by Tetsuo that the following sequence > write_seqlock_irqsave() > printk_deferred_enter() > > could lead to a deadlock if the lockdep annotation within > write_seqlock_irqsave() triggers. The problem is that the sequence > counter is incremented before the lockdep annotation is performed. The > lockdep splat would then attempt to invoke printk() but the reader side, > of the same seqcount, could have a tty_port::lock acquired waiting for > the sequence number to become even again. > > The other lockdep annotations come before the actual locking because "we > want to see the locking error before it happens". There is no reason why > seqcount should be different here. > > Do the lockdep annotation first then perform the locking operation (the > sequence increment). > > Fixes: 1ca7d67cf5d5a ("seqcount: Add lockdep functionality to seqcount/seqlock structures") > Reported-by: Tetsuo Handa > Link: https://lore.kernel.org/20230621130641.-5iueY1I@linutronix.de > Signed-off-by: Sebastian Andrzej Siewior Acked-by: Mel Gorman -- Mel Gorman SUSE Labs