Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3172448ioa; Mon, 25 Apr 2022 20:12:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpcIGYogf90P7/0xCucQlI3RAK9q2clIv7K1Rz4H0NEbWCFvHCFZrWK9YTioCtYhCC0iPP X-Received: by 2002:a17:903:4093:b0:15c:e5eb:9545 with SMTP id z19-20020a170903409300b0015ce5eb9545mr14594315plc.62.1650942777170; Mon, 25 Apr 2022 20:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650942777; cv=none; d=google.com; s=arc-20160816; b=mw82J61bFD9oFMHzDDyd0TqCbAG+dM9GuVkd8fLcKh7mk2oLgoDXxpdRz6o59gtlyF opSa9eWvlAcjjOlUv0jSsEk3dV9SDZc276b+5Bgzc1ykxLv1t3dis5+NzbM3qCzzXwQf sU3ImLgp8u5TfpbBr5sJzwNas4ERwUv3tKZOWnQKbWbI1gPThxzL9ofyht2SGeD9NBs2 cqlGrOAcyKt06/qmWHvDUneCcV9uZ9d3AHkRmGxVWu/kwhbj10b8dZU34QhoKXPFI5p1 E4S3InW6WtinzxtOlt6/K+YeEJGuY6t3nQhgjjZ9wxGoz01WcWQiBGKqt5AB90BQuHQD C+Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=qxGOqtPb2bys/C072ZjZKwxLwn9k6n0Y4ZESfIXyK4k=; b=T74WTLUtZ6OiAoEmoIgxYydYqfwwRCr+l83k5tcM0KH5CRJnIbvFcxFUlCpuATdXVU 1hZ1e+cHjQbzuUk1AQIeI8aspvy2FNSSBU6ay7S3XU4rq/pha6IViVBU3/3gNzq4wxwV wHzVKjHspUUG9NZyCwzh2rshG7rSnNmoFSGhZYNyKSpuqwVnSW3+6nREtJwPGleycA2K mp+2W/T8jbc76YJzPqP68sVhrMXWbaBS0Z1ImfzWxHpO0UDnzlvyAaoBpdmlxyFnBoMU U69QlaEX2UwqErQd9c3skKEwot63ShmTjtqS6KeUzhNBIhGnK8TNNGNuYLyAaSv2Gnll CDyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=v2C6RsB5; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j15-20020a17090a840f00b001d53196eaefsi987674pjn.160.2022.04.25.20.12.40; Mon, 25 Apr 2022 20:12:57 -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; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=v2C6RsB5; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237853AbiDYNUc (ORCPT + 99 others); Mon, 25 Apr 2022 09:20:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232244AbiDYNU1 (ORCPT ); Mon, 25 Apr 2022 09:20:27 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54C0F17E0A for ; Mon, 25 Apr 2022 06:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1650892644; x=1682428644; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=qxGOqtPb2bys/C072ZjZKwxLwn9k6n0Y4ZESfIXyK4k=; b=v2C6RsB5rzSZByxe8ip/tgWeF3gZHxNATOHX6NUaQNJQQbjEgH/4T9Yh c/xJ4tdQzPHZB3zxmHh1/ahiQuNZGetOLuneZSbL5X2szEu2DegzEMXq7 fmSXpCbVhz6TLoV5FN6VxZ6TZoSrb1KpGymVnxwau6OMeAk+w5RSpb92G g=; Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 25 Apr 2022 06:17:24 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 06:17:23 -0700 Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 25 Apr 2022 06:17:21 -0700 Date: Mon, 25 Apr 2022 18:47:17 +0530 From: Mukesh Ojha To: Johannes Berg , CC: , , , , Subject: Re: [PATCH] devcoredump : Serialize devcd_del work Message-ID: <20220425131716.GA16363@hu-mojha-hyd.qualcomm.com> References: <1650364077-22694-1-git-send-email-quic_mojha@quicinc.com> <2a14c4f64ff3e029a76c85d064146e6c303c96bb.camel@sipsolutions.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.47.97.222) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 On Fri, Apr 22, 2022 at 03:53:35PM +0200, Johannes Berg wrote: > On Fri, 2022-04-22 at 15:41 +0200, Johannes Berg wrote: > > On Tue, 2022-04-19 at 15:57 +0530, Mukesh Ojha wrote: > > > In following scenario(diagram), when one thread X running dev_coredumpm() adds devcd > > > device to the framework which sends uevent notification to userspace > > > and another thread Y reads this uevent and call to devcd_data_write() > > > which eventually try to delete the queued timer that is not initialized/queued yet. > > > > > > So, debug object reports some warning and in the meantime, timer is initialized > > > and queued from X path. and from Y path, it gets reinitialized again and > > > timer->entry.pprev=NULL and try_to_grab_pending() stucks. > > > > > > To fix this, introduce mutex to serialize the behaviour. > > > > > > cpu0(X) cpu1(Y) > > > > > > dev_coredump() uevent sent to userspace > > > device_add() =========================> userspace process Y reads the uevents > > > writes to devcd fd which > > > results into writes to > > > > > > devcd_data_write() > > > mod_delayed_work() > > > try_to_grab_pending() > > > del_timer() > > > debug_assert_init() > > > INIT_DELAYED_WORK > > > schedule_delayed_work > > > > > > > Wouldn't it be easier to simply schedule this before adding it to sysfs > > and sending the uevent? > > > > Hm. I think that would solve this problem, but not all of the problems > here ... > > Even with your change, I believe it's still racy wrt. disabled_store(), > since that flushes the work but devcd_data_write() remains reachable > (and might in fact be waiting for the mutex after your change), so I > think we need an additional flag somewhere (in addition to the mutex) to > serialize all of these things against each other. Can we do something like this in v2 https://lore.kernel.org/lkml/1650892193-12888-1-git-send-email-quic_mojha@quicinc.com/ Thanks, -Mukesh > > johannes