Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp968693pxb; Fri, 22 Apr 2022 15:34:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7aBJ8X3l/ZRlCgaTnyF1vAjZYEHW3pGBx4/cl90cC/h/xF8DU5MOH1lcueJIkS4yL/pv5 X-Received: by 2002:a62:e518:0:b0:4fa:9333:ddbd with SMTP id n24-20020a62e518000000b004fa9333ddbdmr7270803pff.11.1650666881062; Fri, 22 Apr 2022 15:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650666881; cv=none; d=google.com; s=arc-20160816; b=fOfV7zZtTvNRQTuiNCvERJ5EoyMyApEB25maf0qgD2p4nUOOS3NxW8jyrSlCCG9Z2s 7cSGI2+bn75x0xKF+O2hWYKEh/NPmOyrUcE70X6IE8/Va5jDPVv4cQs1+p+aa6vdA+C7 LuNQzbKIxVjQBbOA/zbKLyjendCpXBXuZCEmh2RQvVVQ4vC+Mz0dHZZhFIhpR79TbZY7 Hk+o3yiyE2UC2C//zSuhUUxGVjaZP87qv4FSBlHNPADpVV07xh1q0BiHyGj5XCAl50oO a73Ew26Lji5+JYNcfYq0avystzIkKgbtsuE56wcFqt3T6//vx5fku0CBVXZ2fjmyC31U wHJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=N9g5FPfq8uxs/XPuUy8BU7bUC5HJN88qs0ORLOBFKx8=; b=yUAyM1fHQSZqVMIVzCvqXy4G9KX26IAb6QkxdOdoi0OXdNTC5kotLTOSMRhjfP4Vol L0owWQFk3HcGAX1iDY17oZ1Wpb4aHvCnF6ZKfh/RT6BQNNKeMdJuVOpXQQpXEyo//QTv r8H8RO3zepcIJp64+FmhL0dyto0GNI1vMi/PO/xBcVe46NV+mcovR7v3e/f8XndqXn1o 8BkwzAH75Jp+Q4BQQSRLViWD/RaBfGPgZ12IdIPY9GZeKanNy2+A7801HKJf9rztFBaJ EhIy+wYbxeINhtQOqDdpGFXvT3NcWPePUM3bdKoAlhsbDVXILbanLMkUOaOGNYZ98lQz 7XPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=EftaVgC3; 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=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h189-20020a6383c6000000b003aa817ccdf7si7079503pge.54.2022.04.22.15.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:34:41 -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; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=EftaVgC3; 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=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6FDB03B2FC4; Fri, 22 Apr 2022 13:22:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1448106AbiDVN4c (ORCPT + 99 others); Fri, 22 Apr 2022 09:56:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231134AbiDVN4a (ORCPT ); Fri, 22 Apr 2022 09:56:30 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBA0C5A0B1 for ; Fri, 22 Apr 2022 06:53:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=N9g5FPfq8uxs/XPuUy8BU7bUC5HJN88qs0ORLOBFKx8=; t=1650635617; x=1651845217; b=EftaVgC3EVc+9U9M3Fuv0Z6+0+nprkXC/8bSKA6Sm4JmNCr KRgUOloyZR13w/WlygYFKELkdG7tU3JlsIe3sdd4SoO5kIEdy/HYU8/+DqgP1Awcn9eIopSiH9oQF /8201u+Sw6jrCdrVYyhnSz/vlplW+fdd9BBgu8eOMcmZP7q9kUkd6aIKAk5DEJ2rKl6BWWnUljz2E VXxCrQT4kfHw0BJ2IqkMZhRARM50LI2ss+fJqgmK+cvB99puPcrrwgarQL8+dV4z174iIJvYaOHI4 ekNPQhye5OoYDJfdR9un+/QjbOsD/JJRUG7HZEbupCECxfgDWfq7WwgUqSplLe2g==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) (envelope-from ) id 1nhtj6-00DXll-2O; Fri, 22 Apr 2022 15:53:36 +0200 Message-ID: Subject: Re: [PATCH] devcoredump : Serialize devcd_del work From: Johannes Berg To: Mukesh Ojha , linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, sboyd@kernel.org, rafael@kernel.org Date: Fri, 22 Apr 2022 15:53:35 +0200 In-Reply-To: <2a14c4f64ff3e029a76c85d064146e6c303c96bb.camel@sipsolutions.net> References: <1650364077-22694-1-git-send-email-quic_mojha@quicinc.com> <2a14c4f64ff3e029a76c85d064146e6c303c96bb.camel@sipsolutions.net> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-malware-bazaar: not-scanned X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 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. johannes