* RE: [PATCH] mm/page-writeback.c: fix sparse warnings
2009-04-17 5:27 ` Johannes Weiner
@ 2009-04-17 18:01 ` H Hartley Sweeten
2009-04-17 18:13 ` H Hartley Sweeten
1 sibling, 0 replies; 4+ messages in thread
From: H Hartley Sweeten @ 2009-04-17 18:01 UTC (permalink / raw)
To: Johannes Weiner; +Cc: linux-kernel
On Thursday, April 16, 2009 10:28 PM, Johannes Weiner wrote:
> On Thu, Apr 16, 2009 at 09:26:35PM -0400, H Hartley Sweeten wrote:
>> Fix two sparse warnings in mm/page-writeback.c.
>
> You fixed code rather than warnings, right? ;)
Correct. I should have used a different subject...
>> get_dirty_limits() calls clip_bdi_dirty_limit() and
task_dirty_limit()
>> with variable pbdi_dirty as one of the arguments. This variable is
>> an unsigned long * but both functions expect it to be a long *. This
>> causes the following sparse warnings:
>>
>> warning: incorrect type in argument 3 (different signedness)
>> expected long *pbdi_dirty
>> got unsigned long *pbdi_dirty
>> warning: incorrect type in argument 2 (different signedness)
>> expected long *pdirty
>> got unsigned long *pbdi_dirty
>>
>> Fix the warnings by changing the long * to unsigned long * in both
>> functions.
>>
>> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
>>
>> ---
>>
>> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
>> index 30351f0..e40b3e3 100644
>> --- a/mm/page-writeback.c
>> +++ b/mm/page-writeback.c
>> @@ -265,18 +265,20 @@ static void bdi_writeout_fraction(struct
>> backing_dev_info *bdi,
>> * This avoids exceeding the total dirty_limit when the floating
>> averages
>> * fluctuate too quickly.
>> */
>> -static void
>> -clip_bdi_dirty_limit(struct backing_dev_info *bdi, long dirty, long
>> *pbdi_dirty)
>
> Your patches wrap, please fix your mail client to not do this.
Sorry about that. As far as I can tell, wrap occurs when my email
provider
bounces the message. I'm working on trying to get it resolved.
>> +static void clip_bdi_dirty_limit(struct backing_dev_info *bdi,
>> + unsigned long dirty, unsigned long *pbdi_dirty)
>> {
>> - long avail_dirty;
>> + unsigned long avail_dirty;
>> + unsigned long nr_pages;
>>
>> - avail_dirty = dirty -
>> - (global_page_state(NR_FILE_DIRTY) +
>> + nr_pages = global_page_state(NR_FILE_DIRTY) +
>> global_page_state(NR_WRITEBACK) +
>> global_page_state(NR_UNSTABLE_NFS) +
>> - global_page_state(NR_WRITEBACK_TEMP));
>> + global_page_state(NR_WRITEBACK_TEMP);
>>
>> - if (avail_dirty < 0)
>> + if (nr_pages < dirty)
>> + avail_dirty = dirty - nr_pages;
>> + else
>> avail_dirty = 0;
>
> No need for a new variable, especially if nr_pages really counts
> available dirty pages.
>
> avail_dirty = global_page_state() + ...
> if (avail_dirty < dirty)
> avail_dirty = dirty - avail_dirty;
> else
> avail_dirty = 0;
>
> Hm?
True. Didn't think about that.
I will update the patch and resubmit. Unfortunately it will wrap again.
;-)
Regards,
Hartley
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] mm/page-writeback.c: fix sparse warnings
2009-04-17 5:27 ` Johannes Weiner
2009-04-17 18:01 ` H Hartley Sweeten
@ 2009-04-17 18:13 ` H Hartley Sweeten
1 sibling, 0 replies; 4+ messages in thread
From: H Hartley Sweeten @ 2009-04-17 18:13 UTC (permalink / raw)
To: Johannes Weiner; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2330 bytes --]
mm: dirty limit type specifies should be unsigned long
get_dirty_limits() calls clip_bdi_dirty_limit() and task_dirty_limit()
with variable pbdi_dirty as one of the arguments. This variable is
an unsigned long * but both functions expect it to be a long *. This
causes the following sparse warnings:
warning: incorrect type in argument 3 (different signedness)
expected long *pbdi_dirty
got unsigned long *pbdi_dirty
warning: incorrect type in argument 2 (different signedness)
expected long *pdirty
got unsigned long *pbdi_dirty
Fix the warnings by changing the long * to unsigned long * in both
functions.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
---
Patch is also attached due to line wrapping in email.
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 30351f0..ad2a414 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -265,18 +265,19 @@ static void bdi_writeout_fraction(struct
backing_dev_info *bdi,
* This avoids exceeding the total dirty_limit when the floating
averages
* fluctuate too quickly.
*/
-static void
-clip_bdi_dirty_limit(struct backing_dev_info *bdi, long dirty, long
*pbdi_dirty)
+static void clip_bdi_dirty_limit(struct backing_dev_info *bdi,
+ unsigned long dirty, unsigned long *pbdi_dirty)
{
- long avail_dirty;
+ unsigned long avail_dirty;
- avail_dirty = dirty -
- (global_page_state(NR_FILE_DIRTY) +
+ avail_dirty = global_page_state(NR_FILE_DIRTY) +
global_page_state(NR_WRITEBACK) +
global_page_state(NR_UNSTABLE_NFS) +
- global_page_state(NR_WRITEBACK_TEMP));
+ global_page_state(NR_WRITEBACK_TEMP);
- if (avail_dirty < 0)
+ if (avail_dirty < dirty)
+ avail_dirty = dirty - avail_dirty;
+ else
avail_dirty = 0;
avail_dirty += bdi_stat(bdi, BDI_RECLAIMABLE) +
@@ -299,10 +300,10 @@ static inline void task_dirties_fraction(struct
task_struct *tsk,
*
* dirty -= (dirty/8) * p_{t}
*/
-static void task_dirty_limit(struct task_struct *tsk, long *pdirty)
+static void task_dirty_limit(struct task_struct *tsk, unsigned long
*pdirty)
{
long numerator, denominator;
- long dirty = *pdirty;
+ unsigned long dirty = *pdirty;
u64 inv = dirty >> 3;
task_dirties_fraction(tsk, &numerator, &denominator);
[-- Attachment #2: mm_page-writeback_sparse.patch --]
[-- Type: application/octet-stream, Size: 1491 bytes --]
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 30351f0..ad2a414 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -265,18 +265,19 @@ static void bdi_writeout_fraction(struct backing_dev_info *bdi,
* This avoids exceeding the total dirty_limit when the floating averages
* fluctuate too quickly.
*/
-static void
-clip_bdi_dirty_limit(struct backing_dev_info *bdi, long dirty, long *pbdi_dirty)
+static void clip_bdi_dirty_limit(struct backing_dev_info *bdi,
+ unsigned long dirty, unsigned long *pbdi_dirty)
{
- long avail_dirty;
+ unsigned long avail_dirty;
- avail_dirty = dirty -
- (global_page_state(NR_FILE_DIRTY) +
+ avail_dirty = global_page_state(NR_FILE_DIRTY) +
global_page_state(NR_WRITEBACK) +
global_page_state(NR_UNSTABLE_NFS) +
- global_page_state(NR_WRITEBACK_TEMP));
+ global_page_state(NR_WRITEBACK_TEMP);
- if (avail_dirty < 0)
+ if (avail_dirty < dirty)
+ avail_dirty = dirty - avail_dirty;
+ else
avail_dirty = 0;
avail_dirty += bdi_stat(bdi, BDI_RECLAIMABLE) +
@@ -299,10 +300,10 @@ static inline void task_dirties_fraction(struct task_struct *tsk,
*
* dirty -= (dirty/8) * p_{t}
*/
-static void task_dirty_limit(struct task_struct *tsk, long *pdirty)
+static void task_dirty_limit(struct task_struct *tsk, unsigned long *pdirty)
{
long numerator, denominator;
- long dirty = *pdirty;
+ unsigned long dirty = *pdirty;
u64 inv = dirty >> 3;
task_dirties_fraction(tsk, &numerator, &denominator);
^ permalink raw reply related [flat|nested] 4+ messages in thread