mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: 陈玉凡 <chenyufan@vivo.com>
To: "Mikulas Patocka" <mpatocka@redhat.com>, 陈玉凡 <chenyufan@vivo.com>
Cc: Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	"dm-devel@lists.linux.dev" <dm-devel@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	opensource.kernel <opensource.kernel@vivo.com>
Subject: Re: [PATCH v1] Device-mapper(LVM): Convert to use time_after_eq macro
Date: Fri, 23 Aug 2024 09:18:25 +0000	[thread overview]
Message-ID: <bc1025c5-fa3c-4a49-9d91-d2d90e7423b4@vivo.com> (raw)
In-Reply-To: <1abae895-7fb4-0342-21b9-1fd8e085dc9a@redhat.com>

在 2024/8/23 1:08, Mikulas Patocka 写道:
>
> On Thu, 22 Aug 2024, Chen Yufan wrote:
>
>> Use time_after_eq macro instead of opening it for readability.
>>
>> Signed-off-by: Chen Yufan <chenyufan@vivo.com>
>> ---
>>   drivers/md/dm-writecache.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
>> index 7ce8847b3..548d4d37e 100644
>> --- a/drivers/md/dm-writecache.c
>> +++ b/drivers/md/dm-writecache.c
>> @@ -16,6 +16,7 @@
>>   #include <linux/pfn_t.h>
>>   #include <linux/libnvdimm.h>
>>   #include <linux/delay.h>
>> +#include <linux/jiffies.h>
>>   #include "dm-io-tracker.h"
>>   
>>   #define DM_MSG_PREFIX "writecache"
>> @@ -1994,8 +1995,8 @@ static void writecache_writeback(struct work_struct *work)
>>   	while (!list_empty(&wc->lru) &&
>>   	       (wc->writeback_all ||
>>   		wc->freelist_size + wc->writeback_size <= wc->freelist_low_watermark ||
>> -		(jiffies - container_of(wc->lru.prev, struct wc_entry, lru)->age >=
>> -		 wc->max_age - wc->max_age / MAX_AGE_DIV))) {
>> +		(time_after_eq(jiffies, container_of(wc->lru.prev, struct wc_entry, lru)->age +
>> +		 (wc->max_age - wc->max_age / MAX_AGE_DIV))))) {
>>   
>>   		n_walked++;
>>   		if (unlikely(n_walked > WRITEBACK_LATENCY) &&
>> -- 
>> 2.39.0
> I'm not sure about this. The old and new code is not really equivalent.
>
> Mikulas

The code here is susceptible to overflow issues, and the time_*() macros 
can handle this.

Chen
>


  reply	other threads:[~2024-08-23  9:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22  1:54 Chen Yufan
2024-08-22 17:08 ` Mikulas Patocka
2024-08-23  9:18   ` 陈玉凡 [this message]
2024-08-23 19:01     ` Mikulas Patocka
     [not found]       ` <de43d61e-05c0-466f-b004-a97f2bf2ec39@vivo.com>
2024-08-26  9:23         ` Mikulas Patocka
     [not found]           ` <e9a9f9f7-6c38-4ca7-8ccf-40275662cd34@vivo.com>
2024-08-29 16:36             ` Mikulas Patocka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bc1025c5-fa3c-4a49-9d91-d2d90e7423b4@vivo.com \
    --to=chenyufan@vivo.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=opensource.kernel@vivo.com \
    --cc=snitzer@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®