Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp925804pxb; Fri, 22 Apr 2022 14:29:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFWgBC0tDqMSw1NVd4yycpkfGUckJRWwxxtOR32RR0t6mlEwrtwLI/Hfkc3H3f8TGZ5GOp X-Received: by 2002:a05:6a02:19b:b0:39d:cfa:5cda with SMTP id bj27-20020a056a02019b00b0039d0cfa5cdamr5529144pgb.175.1650662992677; Fri, 22 Apr 2022 14:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650662992; cv=none; d=google.com; s=arc-20160816; b=YpWKM2RWazntFnItW4rOgaSzFVKbFUUFQW8MzUXx8AopTrAqUlZl6R3PmllOvrAXkN 0MUEETsx2ARDMHfK7BPGp90CjqqIgB5aEiX1znJtd/ipmdKBH4pucADOPNK2Ub4s6OLm nnwtKTyvNfISRczwBUH+maZqWmCI18rXazKrHI5CxMFtsFcIciwcQ7HgD3oVYVveEWbf 55BzG9vpCy4HZNdaE84iazxHOjVk8FMmfjyHMtlfuezuKhgumdZLRlIp6bYsCFCyG9SI JR0KAnO3wk+cEYHTWQ5M+7hk8jhtw/+pOvjooVB658l7eEKxVz2Pu3d2pEih6PxHxDmD 5iBA== 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; bh=mcUG9jT1MP4gZGzrrHFPQrMBUUAYLB2/16OlxpDgwWY=; b=TCyRYMkt3XKPqanXvBg5ogKK5NY2hphpdOU9vAqhFJWAb6EmtlYlbaJNH298XbfTtK GroMcRC5hO6bP7UcUb97T0gplF++bkF08ngM5gXrQsFfEELIMwBvKZr79SP16o4s7664 2hy3u6+xwnX27ure4uC3TuOzkXtBsdXPvsDmSuWRm4lJ0q4vikyNMHJ+tYFqwnHSpFM9 g+licAsCpJF3PG81LyEeJV+L3ngDlv9a0G7PKXI+asfqgC3YGOh1GkQFNkEiPjsVwn7I PO0qtf4p4W8bTlSIbVwHAtqNKq/V4wqpz15u4KU42OUMmEdB67U+CiyMMPBe1+utHFDg S/vQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w19-20020a170902d71300b00153c0220d44si8717408ply.596.2022.04.22.14.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 14:29:52 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55A07288EE1; Fri, 22 Apr 2022 12:37:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380528AbiDTQ0r (ORCPT + 99 others); Wed, 20 Apr 2022 12:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376497AbiDTQ0p (ORCPT ); Wed, 20 Apr 2022 12:26:45 -0400 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DAAB3D1F3 for ; Wed, 20 Apr 2022 09:23:59 -0700 (PDT) Received: by mail-yb1-f172.google.com with SMTP id h8so3781284ybj.11 for ; Wed, 20 Apr 2022 09:23:59 -0700 (PDT) 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=mcUG9jT1MP4gZGzrrHFPQrMBUUAYLB2/16OlxpDgwWY=; b=nY9QlGpa/L1JQzvLHxjLJvAwIbAq0fWwlRPtc2dM/Ev/sqZs4xZbBEZhdFf8gjK9pX oI0+UKjcVkq1dsmAMwtL/BnPkNT0nHocEJiN0LeuDN0UTut3vd0dU0eTnkvZ7SroHxzS 6ay/yUQ9DVtKIgWjmR2I5MpynMWJHr/+tmB3dw0i6s0Klg7Vy6nyKuWi9oZF94heZrUm PiYeWgfHymwSRU3jae4Z0mZfn/yyxBv411ItBYGvKI4v/+924+JQIXdWM/3Yg6dnsGgi qH6VqgBQAk5TUucZ9uS7rOnKbRKfP2mVz4veDmvIby3vrY0CSGahDas/qqQuoUqHftGJ F2rg== X-Gm-Message-State: AOAM532MMDFYGowkjvnYWCWZ24v+0HIOjC5kkssOB3P8Zlj9Q0AW1UUs bG1uA4WMXYkt9m5L17aqujbWP0r6FmKbOHZjTOSUwAbJ X-Received: by 2002:a25:e082:0:b0:641:cf5:b91f with SMTP id x124-20020a25e082000000b006410cf5b91fmr20653666ybg.482.1650471838920; Wed, 20 Apr 2022 09:23:58 -0700 (PDT) MIME-Version: 1.0 References: <20220420140521.45361-1-kernelfans@gmail.com> <20220420140521.45361-7-kernelfans@gmail.com> In-Reply-To: <20220420140521.45361-7-kernelfans@gmail.com> From: "Rafael J. Wysocki" Date: Wed, 20 Apr 2022 18:23:48 +0200 Message-ID: Subject: Re: [PATCH 6/9] pm/irq: make for_each_irq_desc() safe of irq_desc release To: Pingfan Liu Cc: Linux Kernel Mailing List , Thomas Gleixner , "Rafael J. Wysocki" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE 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 Wed, Apr 20, 2022 at 4:06 PM Pingfan Liu wrote: > > The invloved context is no a RCU read section. Furthermore there may be > more than one task at this point. Hence it demands a measure to prevent > irq_desc from freeing. Use irq_lock_sparse to serve the protection > purpose. Can you please describe an example scenario in which the added locking will prevent a failure from occurring? > Signed-off-by: Pingfan Liu > Cc: Thomas Gleixner > Cc: "Rafael J. Wysocki" > To: linux-kernel@vger.kernel.org > --- > kernel/irq/pm.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel/irq/pm.c b/kernel/irq/pm.c > index ca71123a6130..4b67a4c7de3c 100644 > --- a/kernel/irq/pm.c > +++ b/kernel/irq/pm.c > @@ -133,6 +133,7 @@ void suspend_device_irqs(void) > struct irq_desc *desc; > int irq; > > + irq_lock_sparse(); > for_each_irq_desc(irq, desc) { > unsigned long flags; > bool sync; > @@ -146,6 +147,7 @@ void suspend_device_irqs(void) > if (sync) > synchronize_irq(irq); > } > + irq_unlock_sparse(); > } > EXPORT_SYMBOL_GPL(suspend_device_irqs); > > @@ -186,6 +188,7 @@ static void resume_irqs(bool want_early) > struct irq_desc *desc; > int irq; > > + /* The early resume stage is free of irq_desc release */ > for_each_irq_desc(irq, desc) { > unsigned long flags; > bool is_early = desc->action && > -- > 2.31.1 >