Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1452394 > unrolled thread
| Started by | One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> |
|---|---|
| First post | 2016-07-29 14:50 +0200 |
| Last post | 2016-08-04 08:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] usb:serial: Add Fintek F81532/534 driver One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-07-29 14:50 +0200
Re: [PATCH] usb:serial: Add Fintek F81532/534 driver "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com> - 2016-08-04 08:40 +0200
| From | One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> |
|---|---|
| Date | 2016-07-29 14:50 +0200 |
| Subject | Re: [PATCH] usb:serial: Add Fintek F81532/534 driver |
| Message-ID | <s0foJ-4Gb-9@gated-at.bofh.it> |
O
> +static int f81534_set_normal_register(struct usb_device *dev, u16 reg, u8 data)
> +{
> + size_t count = F81534_USB_MAX_RETRY;
> + int status;
> + u8 *tmp;
> +
> + tmp = kmalloc(sizeof(u8), GFP_KERNEL);
> + if (!tmp)
> + return -ENOMEM;
You end up doing huge numbers of tiny allocation and frees in some of the
code paths. I think it would be better to allocate them at a higher level
as they are not that cheap on CPU time.
> +static int f81534_read_data(struct usb_serial *usbserial, u32 address,
> + size_t size, unsigned char *buf)
> +{
Is a particularly good example - you do 4 mallocs plus two per byte of
data.
Alan
[toc] | [next] | [standalone]
| From | "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com> |
|---|---|
| Date | 2016-08-04 08:40 +0200 |
| Message-ID | <s2ktX-5fC-1@gated-at.bofh.it> |
| In reply to | #1452394 |
Hi Alan,
One Thousand Gnomes 於 2016/7/29 下午 08:48 寫道:
> O
>> +static int f81534_set_normal_register(struct usb_device *dev, u16 reg, u8 data)
>> +{
>> + size_t count = F81534_USB_MAX_RETRY;
>> + int status;
>> + u8 *tmp;
>> +
>> + tmp = kmalloc(sizeof(u8), GFP_KERNEL);
>> + if (!tmp)
>> + return -ENOMEM;
>
> You end up doing huge numbers of tiny allocation and frees in some of the
> code paths. I think it would be better to allocate them at a higher level
> as they are not that cheap on CPU time.
>
>> +static int f81534_read_data(struct usb_serial *usbserial, u32 address,
>> + size_t size, unsigned char *buf)
>> +{
>
> Is a particularly good example - you do 4 mallocs plus two per byte of
> data.
>
I'll re-factor the newest V9 patch with your suggestion. To malloc a
byte within usb_serial privates, and make a mutex to protect it.
I'll send it as V10 when I tested it.
Thanks for your suggestion.
--
With Best Regards,
Peter Hong
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web