netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen@asianux.com>
To: David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>
Subject: Re: [Suggestion] net/core: cpumask_scnprintf, use (PAGE_SIZE - 1) instead of PAGE_SIZE
Date: Wed, 21 Nov 2012 16:07:05 +0800	[thread overview]
Message-ID: <50AC8BA9.7060508@asianux.com> (raw)
In-Reply-To: <50AC8A78.6020707@asianux.com>

Hi David:


sorry it is my fault.

next time, I should check it carefully.


gchen.


于 2012年11月21日 16:02, Chen Gang 写道:
> Hi David
> 
>  also for show_xps_map in net/core/net-sysfs.c
> 
> 
> Regard
> 
> gchen
> 
> 
>  933 static ssize_t show_xps_map(struct netdev_queue *queue,
>  934                             struct netdev_queue_attribute *attribute, char *buf)
>  935 {
>  936         struct net_device *dev = queue->dev;
>  937         struct xps_dev_maps *dev_maps;
>  938         cpumask_var_t mask;
>  939         unsigned long index;
>  940         size_t len = 0;
>  941         int i;
>  942 
>  943         if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
>  944                 return -ENOMEM;
>  945 
>  946         index = get_netdev_queue_index(queue);
>  947 
>  948         rcu_read_lock();
>  949         dev_maps = rcu_dereference(dev->xps_maps);
>  950         if (dev_maps) {
>  951                 for_each_possible_cpu(i) {
>  952                         struct xps_map *map =
>  953                             rcu_dereference(dev_maps->cpu_map[i]);
>  954                         if (map) {
>  955                                 int j;
>  956                                 for (j = 0; j < map->len; j++) {
>  957                                         if (map->queues[j] == index) {
>  958                                                 cpumask_set_cpu(i, mask);
>  959                                                 break;
>  960                                         }
>  961                                 }
>  962                         }
>  963                 }
>  964         }
>  965         rcu_read_unlock();
>  966 
>  967         len += cpumask_scnprintf(buf + len, PAGE_SIZE, mask);
>  968         if (PAGE_SIZE - len < 3) {
>  969                 free_cpumask_var(mask);
>  970                 return -EINVAL;
>  971         }
>  972 
>  973         free_cpumask_var(mask);
>  974         len += sprintf(buf + len, "\n");
>  975         return len;
>  976 }
> 
> 
> 
> 
> 于 2012年11月21日 15:55, Chen Gang 写道:
>> Hi David Miller:
>>
>> in net/core/net-sysfs.c:
>>
>>   at line 496, we need use (PAGE_SIZE -1) instead of PAGE_SIZE.
>>   since at line 505, we append '\n'.
>>
>>   regard
>>
>> gchen
>>
>>
>>  479 static ssize_t show_rps_map(struct netdev_rx_queue *queue,
>>  480                             struct rx_queue_attribute *attribute, char *buf)
>>  481 {
>>  482         struct rps_map *map;
>>  483         cpumask_var_t mask;
>>  484         size_t len = 0;
>>  485         int i;
>>  486 
>>  487         if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
>>  488                 return -ENOMEM;
>>  489 
>>  490         rcu_read_lock();
>>  491         map = rcu_dereference(queue->rps_map);
>>  492         if (map)
>>  493                 for (i = 0; i < map->len; i++)
>>  494                         cpumask_set_cpu(map->cpus[i], mask);
>>  495 
>>  496         len += cpumask_scnprintf(buf + len, PAGE_SIZE, mask);
>>  497         if (PAGE_SIZE - len < 3) {
>>  498                 rcu_read_unlock();
>>  499                 free_cpumask_var(mask);
>>  500                 return -EINVAL;
>>  501         }
>>  502         rcu_read_unlock();
>>  503 
>>  504         free_cpumask_var(mask);
>>  505         len += sprintf(buf + len, "\n");
>>  506         return len;
>>  507 }
>>  508 
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>>
> 
> 


-- 
Chen Gang

Asianux Corporation

      reply	other threads:[~2012-11-21  8:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-21  7:55 [Suggestion] net/core: cpumask_scnprintf, use (PAGE_SIZE - 1) instead of PAGE_SIZE Chen Gang
2012-11-21  8:02 ` Chen Gang
2012-11-21  8:07   ` Chen Gang [this message]

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=50AC8BA9.7060508@asianux.com \
    --to=gang.chen@asianux.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.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;
as well as URLs for NNTP newsgroup(s).