Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7801866pxb; Thu, 18 Feb 2021 22:31:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxm8SsEh5V6StffdSSu+m+48GO7bN4QYYx2EDCGFRA/lkJpQeqUiTgieqSh/lv6GfVN66qt X-Received: by 2002:a50:e0c3:: with SMTP id j3mr7950420edl.32.1613716297715; Thu, 18 Feb 2021 22:31:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613716297; cv=none; d=google.com; s=arc-20160816; b=hk2Tv6nN0CblS+9ibCNs25wqCtkIdtg2iWGCm/HDrvBoUhkLLIst6UXtGUOWfMHWGG okcokzXm4HNvFieDbOYhC4XkjVJ+MqOk5Zg4a0nlG0QVxsu37cdd5tYieAGf/BQifJHG +/yxQJaa5664h7I2RHZ7kkn1YWYSdRWUgqG4TgTgyDm5zVNnSwnW1+NLMt0DLbLkiVBI SB/19sQtJjtbFeMiSYi5qpScZqN5JdAC4/Rob+c59tEaCGvKzj8DZbhDTd7HMKTeSeQ5 1vmTtpgmysEqPdHcBzYl4hK7qoMu1PxaSFBKtEHDt6HCNd+D3BUtsaps0uuLSn5yc0z7 qsTA== 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:dkim-signature; bh=8QbOeYSHoSBYRxmS8POCx9jwvefT3QjgtdlEKLIWRhs=; b=UecWRf/tOLPyMPva3i0c88k2PvG37LwzOpU6eZZ12Fh4DMCteWZ3QnTBsbDyNsai7I yBftFjxgnMgtoqBoW88crltxAVSjeULGqbitoqkWC3b1Dwz47hdQGVauBFFn/AILEjzT 0yOYI16euOT3/HW62RUP8MOTAsuttpSZHv9ctcQiz1EposirS6UOmiKHsLtU96ypC4gr Y+Dba/XiJziW3KFfd9nt/fTPRV645ypeWcvUoLwdw95NzadtJwnAEYg+sXfZ1WSGzHmL WKWoaAbrE01x+Cn/uMs8MnmlGCom44CcwALLVYrQzyqvRbvh9hRJRdzdLXIm9VbNb4MU WFIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=hOGE2ImC; 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=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t15si5236490ejj.506.2021.02.18.22.31.08; Thu, 18 Feb 2021 22:31:37 -0800 (PST) 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=@android.com header.s=20161025 header.b=hOGE2ImC; 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=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229527AbhBSGaU (ORCPT + 99 others); Fri, 19 Feb 2021 01:30:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbhBSGaQ (ORCPT ); Fri, 19 Feb 2021 01:30:16 -0500 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A333C061574 for ; Thu, 18 Feb 2021 22:29:36 -0800 (PST) Received: by mail-qv1-xf34.google.com with SMTP id g3so2164850qvl.2 for ; Thu, 18 Feb 2021 22:29:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8QbOeYSHoSBYRxmS8POCx9jwvefT3QjgtdlEKLIWRhs=; b=hOGE2ImC/+HsdcBOo8ZcsyMxmHF+KAh4wWz2br/79rUxvlQrPDr85SdB4FUleX+rE2 BcZBtaCnpsTeI2kL/HGdzfJDiauWi+l2v7U0HcgqokBkcFyH5csNxpBaNIUqoVQX5TA4 TgasZtrqe//wW7O2Jp0E8D9AdpACA6lBwEttDaik9XBfgmCCacKBSuCALc/Yq4ISoHNt 9p1M2A9fHTprp3SKBOuQMw0Cr0IPkU8jgQRoYXYxhdZmL6BqF4loV4xOYs/6szIvFz2c yeeObXtJBzpWtevCDK6H4zhrgiI8TocPW6VSahNfOWDZ7DQoxiH62MWQ0KCk/YTbaPwy ew4w== 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=8QbOeYSHoSBYRxmS8POCx9jwvefT3QjgtdlEKLIWRhs=; b=YpPjQq07NTHkvkoI73oUI/2LvTKhqNZTp0c9aRCFt+QeEl714cUkzeUmtEn6Y4Zik1 sz9DmH+DgGwGpa21V+WQPf5a8n868t8RxbDUKB9cZ7Wm2M27S84r/ura6ysgIIll2CzJ Df50vOi4xTTspzQrNDL0ppitg7Lc0OI+LeuIxmhFjH8ottI+SHrrrkigKrNiSe+CkqKo c3EdbX5o6ivoZu5a1q1yzx3CwFrSROxxzw0KY42zd8s2XJSJoZlqs2VaaOT2BbwKgxR4 PiSmfowkaPyPU1ih7HKfJtJCmWMkM/z1d3QbmlfEmDBsDa8ve+aLvg1Vkh5mrIIHoqkA bE6g== X-Gm-Message-State: AOAM532V9iW1P+8Dh0k+eqecSSYK0sFE9MQ4yN7/+tObMbNiGOMN4F+h HzI53qvzmKqui7unztBes/1CgzFeCe2j+xbYYQQcGA== X-Received: by 2002:a0c:e80d:: with SMTP id y13mr7811702qvn.2.1613716175541; Thu, 18 Feb 2021 22:29:35 -0800 (PST) MIME-Version: 1.0 References: <20210214000611.2169820-1-zzyiwei@android.com> <20210216091128.GA3973504@infradead.org> In-Reply-To: From: =?UTF-8?B?WWl3ZWkgWmhhbmfigI4=?= Date: Thu, 18 Feb 2021 22:29:24 -0800 Message-ID: Subject: Re: [PATCH] kthread: add kthread_mod_pending_delayed_work api To: Petr Mladek Cc: Christoph Hellwig , Andrew Morton , Felix Kuehling , Jens Axboe , "J. Bruce Fields" , Peter Zijlstra , Frederic Weisbecker , Marcelo Tosatti , Ilias Stamatis , Rob Clark , Mathieu Desnoyers , Liang Chen , Linux Kernel Mailing List , kernel-team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 2. User triggered clean up races with the clean up triggered by > timeout. You try to handle this scenario by this patch. Yes, exactly. > 3. User does clean up after the clean up has already been done > by the timeout. This case is well handled. So only (2) has a potential race. Let me clarify a bit more here. The "clean up" is not the clean up when a process tears down, but it's actually a "post-work" to cancel out an early "pre-work". The "pre-work" enqueues the delayed "post work" for the timeout purpose. That pair of operations can repeatedly happen. The racing is currently worked around by refcounting the delayed_work container, and the later "post-work" will take care of the work deallocation. I mainly want to reach out to see if we agree that this is a valid API to be supported by kthread. Or we extend the existing kthread_mod_delayed_work api to take another option to not re-queue if the cancel failed. Best, Yiwei