Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1564264ybh; Thu, 16 Jul 2020 16:12:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiRbSGZNM/KGrZVcrWTg7L8LmF/V0jN7ZgLfMJb3g4AWTmX9eeCZeVYo/OvhiLGixTHlpF X-Received: by 2002:a17:906:2f17:: with SMTP id v23mr5849691eji.343.1594941161531; Thu, 16 Jul 2020 16:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594941161; cv=none; d=google.com; s=arc-20160816; b=AywIAtz0BOHQtl5L7CKsJQBTFdjT8iw29dFStimV/qM97WRVdmRHoU4Ue0m2CMLwE0 BgcKqzN0fHSS032Osb6H30oPMZTqVPG4c7wNHjw/NL+A8hqb5myDfA3HnktwurOYPFDW 95SdqR8c7R+4iIGMDVmMcxzf6RQWK4d3NAe4uLIQpfGBpYxVEDfxEvKjDVyH2eDcFoqp 0XO9MKxxVDSUHc8s20Jp7ZetyUJEEk3Ei5KDCaZXlrnN7kk0AfCIULW+Vr6hgzpdiQKZ OuPSqtvcMz1nSRqD9RlqqfqKpHqx4EUMHMgUwdMy0RW54wP7GNw2o40v4FOqTcvLyPxn eTaw== 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; bh=fKhPiYD9NcrQRpGcdGZj40gj8kQ14shj2rOSqaCnLy8=; b=mC+g6r/+k0r4LWis423C5K6XliAaD5BUfZxvrDpve3H+THvGK2NauOVAOdy1gfmRiC s+oLdnIWTGeKp19FNu78u1ScJYGt9dx5vqqf1ITap5doQWRGRo7q41uMi7kWPATcdxLP 8kdrYoSNVniF7SAJkCmiBY9KtZocjhZkAmATWynir9t3HBa8RCbrwnUj24VC//3LohGT kKcVf8SzGxQQHwFeDHkj3PMHHj9T+BsbRHTrHB6N+OHr2A4Wp6Llx698FqXbjtVOXj5v tJ4hNXEXFsO7ozOi6pMZxloXJfPIvxoWXcu0s5EaKGuBAIr2ko4j9cyTUtdXgEJvCY/6 vU/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Mst7gel3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si3908001eja.251.2020.07.16.16.12.19; Thu, 16 Jul 2020 16:12:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Mst7gel3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727990AbgGPXJU (ORCPT + 99 others); Thu, 16 Jul 2020 19:09:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727927AbgGPXJS (ORCPT ); Thu, 16 Jul 2020 19:09:18 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABC9FC08C5DC for ; Thu, 16 Jul 2020 15:17:32 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id x72so4352607pfc.6 for ; Thu, 16 Jul 2020 15:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fKhPiYD9NcrQRpGcdGZj40gj8kQ14shj2rOSqaCnLy8=; b=Mst7gel3VBVQzOLyDQc4MiMlTFuTEiShGv3qqgOuhaXUyMGeV4zTgdVmkOgMTj9gKQ z2iOtKgtrQZxHToj4Qz1Q0faDBqYksccsEsRKj8z8QIKGVF0mNdJd6qZSNIfI7xcqeA2 v+DmOEuHmIEMAQVHk4i6Lb8RS5iL58W8azgnQssZ2Lz578yN7dZZRWayMfLPgqFzhe7m lPI3FC0itrcx/3rQgT/Qn1wwGjVH6H8Qq094WgUNOTwF/AP0DIO+pCtocpLliGfy2kr+ Ipq7GN/NuNUe8At/AHKbHMBRGyzr2/wykc43zU8dDXEQ3n/giOipL/YtkEEg4U5tSzw8 D87g== 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=fKhPiYD9NcrQRpGcdGZj40gj8kQ14shj2rOSqaCnLy8=; b=N3flK1R2E3fxYxMIpPhSbz3AnRoE35kmORrJKms65PEWDx8byLjNekyNmcNBHlWQA1 TCTulhQaveHiGZkPHT+exHzLY6K9mPPUCk/3tgTSDWZjJFS3i+lLFNCfdXtTHCXbLuId uHeiuLnrcSOW/pZWZmYizxb2y/ZRI7zKbOHD/iJLoMFao3zNLYEWDF+3ZPBLbuBTk7TO JWs6KrS7w6WWs9dBH2IUB9p0IrH4NGFYhkB0SkfFhVjk2ItM/JBtvDwJ/jmY35y0o/qG t8oCHXkfD/c38F8X+zQP56argkUf4aQJXcfCNBFzWawWalSpaiM5rQoh319C2JTBP66c TGeg== X-Gm-Message-State: AOAM533VIEfI7AqwPykRlU0XnvrnmspMXrC5oshBXe/zb5ulIC5fddQI 5mSz6rWEO3qLXVE+JZIOP84+X+myjFPOF7fgI6d/Og== X-Received: by 2002:a62:8c54:: with SMTP id m81mr5296241pfd.215.1594937851949; Thu, 16 Jul 2020 15:17:31 -0700 (PDT) MIME-Version: 1.0 References: <20200716214523.2924704-1-saravanak@google.com> <6b37125c-96f5-c59c-f170-934d68c9bed1@samsung.com> In-Reply-To: <6b37125c-96f5-c59c-f170-934d68c9bed1@samsung.com> From: Saravana Kannan Date: Thu, 16 Jul 2020 15:16:55 -0700 Message-ID: Subject: Re: [PATCH v2] driver core: Fix sleeping in invalid context during device link deletion To: Marek Szyprowski Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Guenter Roeck , Android Kernel Team , LKML 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 Thu, Jul 16, 2020 at 3:13 PM Marek Szyprowski wrote: > > Hi Saravana, > > On 16.07.2020 23:45, Saravana Kannan wrote: > > Marek and Guenter reported that commit 287905e68dd2 ("driver core: > > Expose device link details in sysfs") caused sleeping/scheduling while > > atomic warnings. > > > > BUG: sleeping function called from invalid context at kernel/locking/mutex.c:935 > > in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 12, name: kworker/0:1 > > 2 locks held by kworker/0:1/12: > > #0: ee8074a8 ((wq_completion)rcu_gp){+.+.}-{0:0}, at: process_one_work+0x174/0x7dc > > #1: ee921f20 ((work_completion)(&sdp->work)){+.+.}-{0:0}, at: process_one_work+0x174/0x7dc > > Preemption disabled at: > > [] srcu_invoke_callbacks+0xc0/0x154 > > ----- 8< ----- SNIP > > [] (device_del) from [] (device_unregister+0x24/0x64) > > [] (device_unregister) from [] (srcu_invoke_callbacks+0xcc/0x154) > > [] (srcu_invoke_callbacks) from [] (process_one_work+0x234/0x7dc) > > [] (process_one_work) from [] (worker_thread+0x44/0x51c) > > [] (worker_thread) from [] (kthread+0x158/0x1a0) > > [] (kthread) from [] (ret_from_fork+0x14/0x20) > > Exception stack(0xee921fb0 to 0xee921ff8) > > > > This was caused by the device link device being released in the context > > of srcu_invoke_callbacks(). There is no need to wait till the RCU > > callback to release the device link device. So release the device > > earlier and move the call_srcu() into the device release code. That way, > > the memory will get freed only after the device is released AND the RCU > > callback is called. > > > > Fixes: 287905e68dd2 ("driver core: Expose device link details in sysfs") > > Reported-by: Marek Szyprowski > > Reported-by: Guenter Roeck > > Signed-off-by: Saravana Kannan > > --- > > > > v1->v2: > > - Better fix > > - Changed subject > > - v1 is this patch https://lore.kernel.org/lkml/20200716050846.2047110-1-saravanak@google.com/ > > > > Marek and Guenter, > > > > I reproduced the original issue and tested this fix. Seems to work for > > me. Can you confirm? > > Confirmed, this one fixes the issue! :) > > Tested-by: Marek Szyprowski Thanks! -Saravana