Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp517224pxb; Mon, 25 Apr 2022 15:22:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa/plqLeMJk8W857Vils3lLlpoq0kp2rmEtv9X+F7LIRACZA7HjHLMtv+cxyLLLHmSOLRD X-Received: by 2002:a17:902:f78d:b0:14f:ce61:eaf2 with SMTP id q13-20020a170902f78d00b0014fce61eaf2mr20505899pln.124.1650925354171; Mon, 25 Apr 2022 15:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650925354; cv=none; d=google.com; s=arc-20160816; b=d/J0scA5vl7XwjpT5KKV2KzQJYlnZ4RtfBQbfRnxUkzG1vKGjbi7cKQzz4ADUa170M WXELhgi1MQ5bVL+IvQ0NrirDEAJrhDB8q1nZjkgL1FMfIei9H+fDg+kVE37ikd9ShbfP jR54Yq9Q5dEc4qcGmKCMAxvd5aw6Q/BkqZNqjhZVSijLPfelQT6dlnagNRiNpahfX5RJ Pv1nfZ45VBd6lMKoybq768N5etvFLeIs02fRAIDIeb19T98xXVB93YDRfYvb1Y/RPZ53 5thk4JlNMiwFi/mHw1I2Y7RehZ63quN/l/zP7K4nOBIf5LdqJQZ0i6T+QKlU9k/dEWHS rg+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to:subject :cc:to:dkim-signature:dkim-signature:from; bh=2XEvTZzG1lvUWu9yjgGpuGqcgvI8ptYR0o+dnNI30nI=; b=sD9tp6JN0e1Lxr+7ez1Z7N7H0xAy6hsNH34lR/LnBOoQW44mcUs7Q7hr1f3nQxHro+ Qbpp2Ytb7AAngiKPnvVEZ1P6BK+G1Nustl4F318pjZREMRlA3XstLy2XooTQIBJsq98B ctD4qNNbYtECt3lziawQ9ZPEQHkn/diQATXsdmC71c5/OEjNU9wWLHGyWjAdhK7qHsjC qsczpBl/azYtAXfhN4RPqT2VYYMViqOkgB4Pq8fFEQpyN8kb8VODsV8IBq5tC9I1V4If P1Ycksc+5RsB2kDHcJ5iE7jrNPPUMy/uE0ZQHuk2esqGGAKKpN8OENESj30BMYjFNqDK IzKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SoTDczs1; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="ARlQ/tM7"; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oo10-20020a17090b1c8a00b001ce45fbb2f6si460164pjb.180.2022.04.25.15.22.15; Mon, 25 Apr 2022 15:22:34 -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=@linutronix.de header.s=2020 header.b=SoTDczs1; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="ARlQ/tM7"; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243682AbiDYRDT (ORCPT + 99 others); Mon, 25 Apr 2022 13:03:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232710AbiDYRDP (ORCPT ); Mon, 25 Apr 2022 13:03:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D91243896 for ; Mon, 25 Apr 2022 10:00:10 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1650906008; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=2XEvTZzG1lvUWu9yjgGpuGqcgvI8ptYR0o+dnNI30nI=; b=SoTDczs1wTsIbA5eWfbR6qdlnC1TCN8JgAwIu3ZM/uRzRdysEKG5QGezmRarqy7ISJnQDu Htrc6UhzsnGFfwSV6u79JohUzEkr7THhtwt2JOOEQSXcRZD1dsPX9kz9/GIa3B1RA/St4J 2IziHn9YxoJFmL+D2srhnbBQrGgndeM4kbboJdNx7l9ZBSrL77KyUSu3KmqhkJXftk62qJ mliUNmkNXJ/VDvDQvp9CxEaiz1eu8lwnHZ/pot8R1etS7qilWoJL6jEx1zd1pUqy4ICt+l EaL8v6X8vLKL1kE2IPdh58KZyTpSCmL/hu7VsFxLkUUhMUsAuAt96DRBGoDOrA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1650906008; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=2XEvTZzG1lvUWu9yjgGpuGqcgvI8ptYR0o+dnNI30nI=; b=ARlQ/tM7TH38XAqnVELArPJ0KBOlCKuu0gnfz7lULdWLe+PjyyLOBVcKzmvgm/1rWUUWR2 n9RquYpzVXu8lRDA== To: Mukesh Ojha , linux-kernel@vger.kernel.org Cc: sboyd@kernel.org, rafael@kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, Mukesh Ojha Subject: Re: [PATCH v2 ] devcoredump : Serialize devcd_del work In-Reply-To: <1650892193-12888-1-git-send-email-quic_mojha@quicinc.com> Date: Mon, 25 Apr 2022 19:00:08 +0200 Message-ID: <87levt14kn.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Mon, Apr 25 2022 at 18:39, Mukesh Ojha wrote: > v1->v2: > - Added del_wk_queued to serialize the race between devcd_data_write() > and disabled_store(). How so? Neither the flag nor the mutex can prevent the race between the work being executed in parallel. disabled_store() worker() class_for_each_device(&devcd_class, NULL, NULL, devcd_free) ... while ((dev = class_dev_iter_next(&iter)) { devcd_del() device_del() put_device() <- last reference error = fn(dev, data) devcd_dev_release() devcd_free(dev, data) kfree(devcd) mutex_lock(&devcd->mutex); There is zero protection of the class iterator against the work being executed and removing the device and freeing its data. IOW, at the point where fn(), i.e. devcd_free(), dereferences 'dev' to acquire the mutex, it might be gone. No? If disabled_store() really needs to flush all instances immediately, then it requires global serialization, not device specific serialization. Johannes, can you please explain whether this immediate flush in disabled_store() is really required and if so, why? Thanks, tglx