From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2064FC433ED for ; Tue, 4 May 2021 16:18:20 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A572611AD for ; Tue, 4 May 2021 16:18:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A572611AD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=vt.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1ldxkJ-0007tv-Fa; Tue, 04 May 2021 12:18:03 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1ldxkG-0007tP-5D for kernelnewbies@kernelnewbies.org; Tue, 04 May 2021 12:18:00 -0400 Received: by mail-qt1-x82a.google.com with SMTP id j19so3852370qtp.7 for ; Tue, 04 May 2021 09:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vt-edu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:in-reply-to:references:mime-version :content-transfer-encoding:date:message-id; bh=4WEaoaiQQtW4T50HucoSjBqIagg4xufEjMHN8oYMg4M=; b=hmApqG1g4Lxnfxl1aQEFYHmKFdJCibChseARe3IWlTxev2MOq/71AMvS5gBNZYKitP hJeEX2rzRFA5BWJRyUWxJJ0j28d6qaxZAvFZr5V6fGv2jwWfD4tsGaliNalvQGef3KOL u1HNmGZ+LvFsaA1IFwYn1az2BVH7xQ1BzgvvrN6R5upm2hEEnwhoQLpAeg8v0P8DplMf pc8d42aEsAh3i9RpZ+VGUElHZPjLrxrDC89Co6iVacpL6KKpljJSkovxTpm+r9RiuC91 I/VNTdfoWErZP6ZkA3TDCKjx48q6GUn1DsRMWkNsOfgzLljeH6bdMhyjysl9kj09oxh+ 4yUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to:references :mime-version:content-transfer-encoding:date:message-id; bh=4WEaoaiQQtW4T50HucoSjBqIagg4xufEjMHN8oYMg4M=; b=WmHJLqz8SK+jM7xz43UETqivd2bR72zR4YciNxxb+WPzlEDRaM7f66AATn0H7wAeLc DQ34jmJhCw9Tmec/RhUuAt6X8sm+zj2o87gXsHpHkw1GJJmJAUDuzwx/0zLgMu4XCl21 el1duzcyeFBkWn0WSOmJs+u11zvEhtpzIAfzYcLQPJ55Li6BOT6UpXLoUlKNDHkAtDi1 e0Xo4ZAOaqjVkgZG//3H3nj2p/XMTVKvkSpS+N93b0dQiAVVTdylbWdM/JsHBcV++9qY ems2rJ/5VxACa4MYZzV29dUQ1Oc2O6MLPEEU3Bw+Gd5o3i41E48fEjvbbYB3J0K9hgis x8oQ== X-Gm-Message-State: AOAM530pmOs4lmMo6IAVe12IJG9lAmiG9rhYD3xyo+NliJFzAxe7RQfW u8wS0JALDOWnMsd1uQoiT3ZbaYIBp4WHxw== X-Google-Smtp-Source: ABdhPJwnStehYdcs26lV5iII7YuvxxCNs5Yeg92WPsb2Odm4Nr+BP8qf0cnKyIRcyEE0noX+ljJBNw== X-Received: by 2002:ac8:4641:: with SMTP id f1mr8914036qto.107.1620145078182; Tue, 04 May 2021 09:17:58 -0700 (PDT) Received: from turing-police ([2601:5c0:c380:d61::359]) by smtp.gmail.com with ESMTPSA id l16sm2736275qtr.65.2021.05.04.09.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 May 2021 09:17:57 -0700 (PDT) From: "Valdis Kl=?utf-8?Q?=c4=93?=tnieks" X-Google-Original-From: "Valdis Kl=?utf-8?Q?=c4=93?=tnieks" X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7+dev To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: Re: deleting timer that re-registers itself In-Reply-To: References: Mime-Version: 1.0 Date: Tue, 04 May 2021 12:17:56 -0400 Message-ID: <323231.1620145076@turing-police> Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============3100893061211049307==" Errors-To: kernelnewbies-bounces@kernelnewbies.org --===============3100893061211049307== Content-Type: multipart/signed; boundary="==_Exmh_1620145076_279505P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit --==_Exmh_1620145076_279505P Content-Type: text/plain; charset=us-ascii On Tue, 04 May 2021 23:59:12 +0900, Hyeonggon Yoo said: > Does del_timer work well for timers that re-registers itself? > what if the timer is currently running, and del_timer is called, > and the running timer re-registers itself? Minor nit: while the timer is running, there's no problem. When the timer has *expired* and timer_callback() is running is when you have a race condition. So who's going to call del_timer()? The only thing that does that is timer_exit. Soo... Apply some silly locking: static int exiting = 0; void timer_callback(struct timer_list *timer) { struct timer_data *data = from_timer(data, timer, timer); data->value++; printk(KERN_INFO "[%s] value is = %d\n", __func__, data->value); if (!exiting) mod_timer(timer, jiffies + DELAY); } void __exit timer_exit(void) { exiting = 1; int ret = del_timer(&data.timer); printk("[%s] deleting timer..., ret = %d\n", __func__, ret); } --==_Exmh_1620145076_279505P Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Comment: Exmh version 2.9.0 11/07/2018 iQIVAwUBYJFzswdmEQWDXROgAQKNDA/9FAm1gbpY+3O3ehO+d0UlrVI/0jJ9MxUJ ET7Rc4VWcgYkLllHGseRp9NFbQfbrpDrMnXOce1doWyv0f+6WUwk+xa0jthVxKNb j7pBiTxo8AUD7b/PRyAxpWH3PEmGaYBkPzllBGiDfir40s35lXjPRt0XBu5Xwdym q7XLwjTqpMIJjhjCZ8StpizKz8omGbE36vfjPYW1Y1miVw3FuFsIZ/iE+qcR0S74 +X4O6bgZPZZNUTp+KcgFccl92gW5GOAfEePdeO+Beg68WSikMk9CmklkqY4BOuNK M/pR0mGLP4PjHE1d3ycMWhUWgMtap8c35BL1j+EQJlnviHkoucnmpiXLB2+xNogj 75bTvqBpd90IzKv0T32OlEMNlbMfMxIqVoI5/WFPGTV68NyuJt83yfC3urgnDdwv q98cQRcNh27iWw5bYSDMPtesv+FJlQllsVvrds6vFdkqSdEJZe2+2J+HEJEW9VSm nnL6FIAodHe9O+yrpJNQBZS/v9Rulutf5RPuwzS8u+zS0Qp0m24p7STnoTljwEDV Z/GR2Mfpio0gahxJzdMa3lNX7zl/Wu5dhxk41YibOpejYta04qtt8cT+DAb1eoxe ddS9j+MZBlmeDaFPToud+ZnPvf6gDsI3jjNa9EfbSksWtaOwAth/4orZFwoTNv/U +1nDDsZ06Xo= =29Wk -----END PGP SIGNATURE----- --==_Exmh_1620145076_279505P-- --===============3100893061211049307== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============3100893061211049307==--