Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1485001

Re: [ISSUE] Memleak in LED sysfs on heavy usage

From Jacek Anaszewski <j.anaszewski@samsung.com>
Newsgroups linux.kernel
Subject Re: [ISSUE] Memleak in LED sysfs on heavy usage
Date 2016-09-16 15:50 +0200
Message-ID <si1GF-5m2-3@gated-at.bofh.it> (permalink)
References <shVUB-1AV-5@gated-at.bofh.it> <shZvg-40T-5@gated-at.bofh.it> <si1GF-5m2-5@gated-at.bofh.it> <si07U-4uJ-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 09/16/2016 02:08 PM, Daniel Gorsulowski wrote:
> Hi Jacek,
>
> Am 16.09.2016 um 13:25 schrieb Jacek Anaszewski:
>> On 09/16/2016 10:15 AM, Daniel Gorsulowski wrote:
>>> Hi Jacek,
>>>
>>> Am 16.09.2016 um 09:31 schrieb Jacek Anaszewski:
>>>> Hi Daniel,
>>>>
>>>> On 09/12/2016 10:50 AM, Daniel Gorsulowski wrote:
>>>>> Hello!
>>>>>
>>>>> Please consider if I made something wrong, sending this issue. This is
>>>>> my first contact to the LKML.
>>>>> By mistake, I accessed an LED via /sys/class/leds subsystem very
>>>>> fast in
>>>>> an user application. I figured out, that the free user memory
>>>>> decreased
>>>>> constantly. So I tried to analyze the Problem and wrote a litte
>>>>> script:
>>>>>
>>>>> #!/bin/sh
>>>>> while [ 1 ]; do
>>>>>         echo 1 > /sys/class/leds/2a_service_yellow/brightness
>>>>>         echo 0 > /sys/class/leds/2a_service_yellow/brightness
>>>>> done
>>>>>
>>>>> And voila, I was able to reproduce the problem.
>>>>> So I add a bit more debugging:
>>>>>
>>>>> #!/bin/sh
>>>>> cnt=0
>>>>> while [ 1 ]; do
>>>>>         if [ `expr $cnt % 1000` -eq 0 ]; then
>>>>>                 free | grep Mem: | cut -d' ' -f25
>>>>>         fi
>>>>>         echo 1 > /sys/class/leds/2a_service_yellow/brightness
>>>>>         echo 0 > /sys/class/leds/2a_service_yellow/brightness
>>>>>         let "cnt++"
>>>>> done
>>>>>
>>>>> And huh? No memory is eaten anymore. So it looks like, the problem
>>>>> only
>>>>> occours on heavy (fast) usage of /sys/class/leds subsystem.
>>>>>
>>>>> I rewrote the script and toggled a GPIO pin, but there was no problem
>>>>> recognizable.
>>>>
>>>> I've been unable to reproduce the problem with leds-aat1290 driver
>>>> and Samsung M0 board. It must be driver specific issue.
>>>> What driver did you use?
>>>>
>>> I defined LEDS_GPIO and so I'm using leds-gpio driver.
>>> danielg@debby:~/opt/prj/ti-linux-kernel$ cat .config | grep LEDS | grep
>>> -v "^# "
>>> CONFIG_INPUT_LEDS=y
>>> CONFIG_NEW_LEDS=y
>>> CONFIG_LEDS_CLASS=y
>>> CONFIG_LEDS_GPIO=y
>>> CONFIG_LEDS_TRIGGERS=y
>>> CONFIG_LEDS_TRIGGER_TIMER=y
>>> CONFIG_LEDS_TRIGGER_ONESHOT=y
>>> CONFIG_LEDS_TRIGGER_HEARTBEAT=y
>>> CONFIG_LEDS_TRIGGER_GPIO=y
>>> CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
>>> CONFIG_LEDS_TRIGGER_TRANSIENT=y
>>>
>>
>> Unfortunately I am still unable to reproduce the problem with leds-gpio.
>> I'm not observing any heavy usage with your test case:
>>
>> ~#free
>>               total       used       free     shared    buffers
>> cached
>> Mem:       1028092      61364     966728          0       8416      22396
>> -/+ buffers/cache:      30552     997540
>> Swap:            0          0          0
>>
>>
>> Actually you didn't give any numbers. What kernel version are you using?
>>
> As I wrote, the problems occurred in vanilla 4.6 kernel, but also in 4.4
> kernel (with PREEMPT-RT Patchset).

Heh, funny coincidence. I was testing this on recent linux-leds.git,
for-next branch and was not able to detect the issue. It started to
appear after resetting HEAD to 4.8-rc2 base. Finally it turned out
that what fixes the issue is the most recent commit [1].

Further investigation revealed that this is kobject_uevent_env(),
called from led_trigger_set(), which causes memory leaks when called
with high frequency.

CC GregKH.

[1] 
https://git.kernel.org/cgit/linux/kernel/git/j.anaszewski/linux-leds.git/commit/?h=for-next&id=f3f624941be0fafb29fff5c1411fa433feca792c

-- 
Best regards,
Jacek Anaszewski

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[ISSUE] Memleak in LED sysfs on heavy usage Daniel Gorsulowski <daniel.gorsulowski@esd.eu> - 2016-09-12 11:00 +0200
  Re: [ISSUE] Memleak in LED sysfs on heavy usage Jacek Anaszewski <j.anaszewski@samsung.com> - 2016-09-13 09:20 +0200
  Re: [ISSUE] Memleak in LED sysfs on heavy usage Jacek Anaszewski <j.anaszewski@samsung.com> - 2016-09-16 09:40 +0200
    Re: [ISSUE] Memleak in LED sysfs on heavy usage Daniel Gorsulowski <daniel.gorsulowski@esd.eu> - 2016-09-16 10:20 +0200
      Re: [ISSUE] Memleak in LED sysfs on heavy usage Jacek Anaszewski <j.anaszewski@samsung.com> - 2016-09-16 13:30 +0200
        Re: [ISSUE] Memleak in LED sysfs on heavy usage Daniel Gorsulowski <daniel.gorsulowski@esd.eu> - 2016-09-16 14:10 +0200
          Re: [ISSUE] Memleak in LED sysfs on heavy usage Jacek Anaszewski <j.anaszewski@samsung.com> - 2016-09-16 15:50 +0200
            Re: [ISSUE] Memleak in LED sysfs on heavy usage Greg KH <greg@kroah.com> - 2016-09-16 16:10 +0200
              Re: [ISSUE] Memleak in LED sysfs on heavy usage Jacek Anaszewski <j.anaszewski@samsung.com> - 2016-09-16 16:40 +0200
                Re: [ISSUE] Memleak in LED sysfs on heavy usage Greg KH <greg@kroah.com> - 2016-09-16 16:50 +0200
                Re: [ISSUE] Memleak in LED sysfs on heavy usage Jacek Anaszewski <jacek.anaszewski@gmail.com> - 2016-09-16 21:00 +0200
                Re: [ISSUE] Memleak in LED sysfs on heavy usage Greg KH <greg@kroah.com> - 2016-09-16 21:50 +0200
                Re: [ISSUE] Memleak in LED sysfs on heavy usage Jacek Anaszewski <jacek.anaszewski@gmail.com> - 2016-09-16 23:10 +0200
                Re: [ISSUE] Memleak in LED sysfs on heavy usage Jacek Anaszewski <j.anaszewski@samsung.com> - 2016-09-19 10:40 +0200
            Re: [ISSUE] Memleak in LED sysfs on heavy usage Daniel Gorsulowski <daniel.gorsulowski@esd.eu> - 2016-09-19 06:40 +0200

csiph-web