Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7056165rwb; Mon, 12 Dec 2022 09:29:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf6FXH60sozLa5tKHhCd9jIxmG7apHh3FppEmDpv6WT9fdN2lEFrKNdOZaLdqpujHPwgvLvp X-Received: by 2002:a17:906:40ce:b0:7c0:e4b7:517e with SMTP id a14-20020a17090640ce00b007c0e4b7517emr13094025ejk.16.1670866177838; Mon, 12 Dec 2022 09:29:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670866177; cv=none; d=google.com; s=arc-20160816; b=V6jEWDQoV9zmcljGMQVq7kC920kH+58S1P5sImrYKMRwdvPrxPD8aA+6ADHIlaYrB+ HrZOomcse6E3xIt8SnnRNGXH7I9zu1Eu+OJGGOm3X0wuIRTxIjysZGjf2buuXDaWCdaq ekbUDMSLplvXKBjfllC/FS7x5xXv47umagXGxzYn7418mn+4DtyMG4abyYy/hns0P0dG kb1DLZTF5qfguiG3gcKb12yV3wuYKYJopwGUP8444Trcoo2eA3P5s0sx8P6IMRS7Ef1I b3jI6ZOjMqYeGqjKBcyPeDqBuWLCLCD7Cdhfg9Qcoglzc0dcVrrkaraxx6N3MvrXoA6l 8bnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=1vAJzLeJNGgmxOrj/60MKDysZQML2TAd12qLdKnNzTg=; b=RKjZlqxJlR68OSujwXZjigLKCGptdyrEc+9AXdlbbX0TWN+J4HHxpNrMwAsPbbW3b9 qw2wfc4ymuKfU/hYZ4yD27MFL8tZy5c9kjk+98xDWoj7Tqvp/s/rRdhcu4sTwD86k8R0 eCzR7UMtb4IMgRCp9LsZ7pkSr5S+ke30BE+l4PD7FZA3cvJ/eTK7lLpU6dYu0IY6Y6v0 Xo1mcaRrNhL+FIi0OQjSAnCOmOSQmKNdj8YatlInxTKmMi5qYDLJeYSNhOprrPxbovm4 NAQAqxTJWXXe6V3k5aBU02MigreNsT0BlYmDyNbJm328G1Zv4LBeqFQnDhXOx8mSw72B uxmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b="H328/QFi"; 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=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn11-20020a1709070d0b00b007ae2b7df929si7109350ejc.72.2022.12.12.09.29.20; Mon, 12 Dec 2022 09:29:37 -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=@siemens.com header.s=fm1 header.b="H328/QFi"; 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=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232938AbiLLQlB (ORCPT + 74 others); Mon, 12 Dec 2022 11:41:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232738AbiLLQkd (ORCPT ); Mon, 12 Dec 2022 11:40:33 -0500 X-Greylist: delayed 62 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 12 Dec 2022 08:38:30 PST Received: from mta-64-225.siemens.flowmailer.net (mta-64-225.siemens.flowmailer.net [185.136.64.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63B7B14D16 for ; Mon, 12 Dec 2022 08:38:30 -0800 (PST) Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 20221212163725ce6f2961f89eb5ceff for ; Mon, 12 Dec 2022 17:37:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=alexander.sverdlin@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc; bh=1vAJzLeJNGgmxOrj/60MKDysZQML2TAd12qLdKnNzTg=; b=H328/QFib50NvLSLJQ/fe7dL+n31eoGcyPfK/JA2+/ihbJPgDCYQqBzdZboiau9QBveU1u u5e3Q7hZvgEB5P9KGJlz0C/LQFtVLBOGED0BQtkkINIz/o5gSyfpK6P/FuQq/ISDUy3k83E1 +8imE4N4Sjqfl6H+n5Akpp0r7V9/U=; From: "A. Sverdlin" To: linux-doc@vger.kernel.org Cc: Alexander Sverdlin , Jonathan Corbet , Federico Vaga , Thomas Gleixner , Ingo Molnar , Manfred Spraul , linux-kernel@vger.kernel.org Subject: [PATCH] docs: kernel-hacking: discourage from calling disable_irq() in atomic Date: Mon, 12 Dec 2022 17:37:15 +0100 Message-Id: <20221212163715.830315-1-alexander.sverdlin@siemens.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-456497:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS 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 From: Alexander Sverdlin Correct the example in documentation so that disable_irq() is not being called in atomic context and remove the comment allowing to do so "with care" from the function header itself. disable_irq() calls sleeping synchronize_irq(), it's not allowed to call them in atomic context. Link: https://lore.kernel.org/lkml/87k02wbs2n.ffs@tglx/ Signed-off-by: Alexander Sverdlin --- Documentation/kernel-hacking/locking.rst | 4 ++-- Documentation/translations/it_IT/kernel-hacking/locking.rst | 4 ++-- kernel/irq/manage.c | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Documentation/kernel-hacking/locking.rst b/Documentation/kernel-hacking/locking.rst index 6805ae6e86e65..95fd6e0900d92 100644 --- a/Documentation/kernel-hacking/locking.rst +++ b/Documentation/kernel-hacking/locking.rst @@ -1274,11 +1274,11 @@ Manfred Spraul points out that you can still do this, even if the data is very occasionally accessed in user context or softirqs/tasklets. The irq handler doesn't use a lock, and all other accesses are done as so:: - spin_lock(&lock); + mutex_lock(&lock); disable_irq(irq); ... enable_irq(irq); - spin_unlock(&lock); + mutex_unlock(&lock); The disable_irq() prevents the irq handler from running (and waits for it to finish if it's currently running on other CPUs). diff --git a/Documentation/translations/it_IT/kernel-hacking/locking.rst b/Documentation/translations/it_IT/kernel-hacking/locking.rst index 51af37f2d6210..bfbada56cf351 100644 --- a/Documentation/translations/it_IT/kernel-hacking/locking.rst +++ b/Documentation/translations/it_IT/kernel-hacking/locking.rst @@ -1309,11 +1309,11 @@ se i dati vengono occasionalmente utilizzati da un contesto utente o da un'interruzione software. Il gestore d'interruzione non utilizza alcun *lock*, e tutti gli altri accessi verranno fatti così:: - spin_lock(&lock); + mutex_lock(&lock); disable_irq(irq); ... enable_irq(irq); - spin_unlock(&lock); + mutex_unlock(&lock); La funzione disable_irq() impedisce al gestore d'interruzioni d'essere eseguito (e aspetta che finisca nel caso fosse in esecuzione su diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 40fe7806cc8c9..2054de5bf3c53 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -722,8 +722,6 @@ EXPORT_SYMBOL(disable_irq_nosync); * This function waits for any pending IRQ handlers for this interrupt * to complete before returning. If you use this function while * holding a resource the IRQ handler may need you will deadlock. - * - * This function may be called - with care - from IRQ context. */ void disable_irq(unsigned int irq) { -- 2.34.1