Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5266800rwj; Tue, 20 Dec 2022 23:43:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXvevHNi+X++43ATDpc6iLUva/SCl7l1m5YrRd0ktTIPvx6WrW2ZnVcXOarTI166TOyuqdcy X-Received: by 2002:a17:90b:3597:b0:214:222:6ed3 with SMTP id mm23-20020a17090b359700b0021402226ed3mr1142895pjb.43.1671608628332; Tue, 20 Dec 2022 23:43:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671608628; cv=none; d=google.com; s=arc-20160816; b=YX6RmwTOGVM65rlhb/6hKfLMk9B4PtrhZBORbepM/pEUhw0iQyZWyoiQjLjwGhn86S aFoO9oFj514MSo4zU6ATkAynHbqbRcN0yuIffHKfqoGEyIzUQ6MhLpsoC9pCG9yy4WFz ZL6zSjoB1U8eCmx9zFdnuVcUxgFGjEgwNggh1lF7da+5nmvtP1EmsMW5cagGPRvaA5RP eHarFyW6FEFJKFxaoDMrXk/+D0+VoW95Pmqz6ul7uvrJvy0y0PiUpHMhliLLfSBzlTVt YQbQ7DhPe7nRe89atGswGm2wdS7UbRtidEVN7vTQEg83mCYRshsyRRi3MaB3Vm/QDQK0 Jgcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-signature; bh=98FzgRVxy4Fva2E1rDjK+d2VOJsSTFywu3YKMe9f7Vs=; b=k89DKGwxmq7Tuqb8PAjc78uXBns/Bbwp/7h2Hy9Sr+W6G6zNGJinYv0DJPznX/6pp7 ++BWhJgugTIueBStVsU9RORRTKb1iqbcc3SS5ae39FhWs2O7W+RLOY0wsmwYt3dnxCW2 nhI2VIxqaViUEkTVFHI5D+99lb9LNflecyJgFVrtoqqhOzLuTI944uHUXmsVPq9Roulw LZQmkkyjhgAEKOA/OgtIV16QYyUWgnhYZJjcGxDQDVnJEGhz5ZfbWhXsU1QKMNscmzI/ E2Fy49XPPEl92iadZWAAJ+Z9Q7BZvsqUiQkOzoX3I09rS4t/JshtfgSlmIAVurUlaCiv 5tmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=hWwX6B24; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=ceVnQHDO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a17090a694200b00202b78e2adasi1060761pjm.102.2022.12.20.23.43.39; Tue, 20 Dec 2022 23:43:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=hWwX6B24; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=ceVnQHDO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234061AbiLUHPZ (ORCPT + 69 others); Wed, 21 Dec 2022 02:15:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbiLUHPW (ORCPT ); Wed, 21 Dec 2022 02:15:22 -0500 Received: from domac.alu.hr (domac.alu.hr [IPv6:2001:b68:2:2800::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00252205CF for ; Tue, 20 Dec 2022 23:15:20 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id 87647604F1; Wed, 21 Dec 2022 08:15:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1671606918; bh=ZtlAaE33ZZV4SRhYl62x38s2P5dFAXk9MtedaQ1GwJQ=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=hWwX6B24XRPEiDD2g8Ml63SL7ENYpyECRW9YB50LlNx+drKGlbOuE7s5md1Th28cv +ccKC11cSq5YI7bDaP+9Z1qNvtZ8a57f57OHLvX7H5AUq/VPpOUD+ZgF5B1vCC9Q2E 2zZRJCLduZ8KGaovktZl9J5qE4mL3cGIG5Ob5f03vCmiowQpJPqtNRh33Ax10qYUbC CgbwQx0bUXtcqT18MKxZnOUaOtY8jwfuzySMAw0oe+siQF6OqB0CSOBTqkcQ5IgGrJ j6S8o8oR3BLKFJOjWvIRO2b6iYCld6227Cu6JloummITDyb/3Q9HTH1lJCgbv78ldF MPyWM8ubaHVnA== X-Virus-Scanned: Debian amavisd-new at domac.alu.hr Received: from domac.alu.hr ([127.0.0.1]) by localhost (domac.alu.hr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R7N6VywRqYZj; Wed, 21 Dec 2022 08:15:16 +0100 (CET) Received: from [10.0.1.53] (grf-nat.grf.hr [161.53.83.23]) by domac.alu.hr (Postfix) with ESMTPSA id 6EE20604EE; Wed, 21 Dec 2022 08:15:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1671606915; bh=ZtlAaE33ZZV4SRhYl62x38s2P5dFAXk9MtedaQ1GwJQ=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=ceVnQHDOpjRUL+PgA+ZT+1TNTr0uObNSZc8akBXH/X8eK6a89Sw81T5Dkwdy1twZJ b6ycWGWDkW4aezlJBNgWTYhpEyxbJb9J9sM7i1P62T3QGSr3YzdBPRYEnk0Arjhra9 aweo8EoP82Fzi21UugOgZB0DGj5l85++xEts2XtI9QGYfqHYMFZ4TRW1xU22b95N/Y imradjcpUjYplRdJOHzclUYN0KUWpxmuJf9J1HmnwoxC5NaK7LeHdJ8Tqx6uZACwsC iCwhpkQor9c7bd4dBvROSCrfxgMMEMvooBQvKiwmt+mhTMw1x7B1nGNHowDVVkyChf DltNLxhfxnRoQ== Message-ID: <24360ef5-a088-58be-d03e-e72ed63d0e13@alu.unizg.hr> Date: Wed, 21 Dec 2022 08:15:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: Possible regression in drm/i915 driver: memleak From: Mirsad Goran Todorovac To: Tvrtko Ursulin , srinivas pandruvada , LKML , jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, Rodrigo Vivi Cc: Thorsten Leemhuis , intel-gfx@lists.freedesktop.org References: <05424a5351a847786377a548dba0759917d8046c.camel@linux.intel.com> <15ef1bb9-7312-5d98-8bf0-0af1a37cfd2a@linux.intel.com> <619bdecc-cf87-60a4-f50d-836f4c073ea7@alu.unizg.hr> Content-Language: en-US In-Reply-To: <619bdecc-cf87-60a4-f50d-836f4c073ea7@alu.unizg.hr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20.12.2022. 20:34, Mirsad Todorovac wrote: > On 12/20/22 16:52, Tvrtko Ursulin wrote: > >> On 20/12/2022 15:22, srinivas pandruvada wrote: >>> +Added DRM mailing list and maintainers >>> >>> On Tue, 2022-12-20 at 15:33 +0100, Mirsad Todorovac wrote: >>>> Hi all, >>>> >>>> I have been unsuccessful to find any particular Intel i915 maintainer >>>> emails, so my best bet is to post here, as you will must assuredly >>>> already know them. >> >> For future reference you can use >> ${kernel_dir}/scripts/get_maintainer.pl -f ... >> >>>> The problem is a kernel memory leak that is repeatedly occurring >>>> triggered during the execution of Chrome browser under the latest >>>> 6.1.0+ >>>> kernel of this morning and Almalinux 8.6 on a Lenovo desktop box >>>> with Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz CPU. >>>> >>>> The build is with KMEMLEAK, KASAN and MGLRU turned on during the >>>> build, >>>> on a vanilla mainline kernel from Mr. Torvalds' tree. >>>> >>>> The leaks look like this one: >>>> >>>> unreferenced object 0xffff888131754880 (size 64): >>>>     comm "chrome", pid 13058, jiffies 4298568878 (age 3708.084s) >>>>     hex dump (first 32 bytes): >>>>       01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >>>> ................ >>>>       00 00 00 00 00 00 00 00 00 80 1e 3e 83 88 ff ff >>>> ...........>.... >>>>     backtrace: >>>>       [] slab_post_alloc_hook+0xb2/0x340 >>>>       [] __kmem_cache_alloc_node+0x1bf/0x2c0 >>>>       [] kmalloc_trace+0x2a/0xb0 >>>>       [] drm_vma_node_allow+0x45/0x150 [drm] >>>>       [] __assign_mmap_offset_handle+0x615/0x820 >>>> [i915] >>>>       [] i915_gem_mmap_offset_ioctl+0x77/0x110 >>>> [i915] >>>>       [] drm_ioctl_kernel+0x181/0x280 [drm] >>>>       [] drm_ioctl+0x2dd/0x6a0 [drm] >>>>       [] __x64_sys_ioctl+0xc4/0x100 >>>>       [] do_syscall_64+0x58/0x80 >>>>       [] entry_SYSCALL_64_after_hwframe+0x72/0xdc >>>> >>>> The complete list of leaks in attachment, but they seem similar or >>>> the same. >>>> >>>> Please find attached lshw and kernel build config file. >>>> >>>> I will probably check the same parms on my laptop at home, which is >>>> also >>>> Lenovo, but a different hw config and Ubuntu 22.10. >> >> Could you try the below patch? >> >> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c >> b/drivers/gpu/drm/i915/gem/i915_gem_mman.c >> index c3ea243d414d..0b07534c203a 100644 >> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c >> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c >> @@ -679,9 +679,10 @@ mmap_offset_attach(struct drm_i915_gem_object *obj, >>   insert: >>          mmo = insert_mmo(obj, mmo); >>          GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo); >> -out: >> + >>          if (file) >>                  drm_vma_node_allow(&mmo->vma_node, file); >> +out: >>          return mmo; >> >>   err: >> >> Maybe it is not the best fix but curious to know if it will make the >> leak go away. > > Hi, > > After 27 minutes uptime with the patched kernel it looks promising. > It is much longer than it took for the buggy kernel to leak slabs. > > Here is the output: > > [root@pc-mtodorov marvin]# echo scan > /sys/kernel/debug/kmemleak > [root@pc-mtodorov marvin]# cat !$ > cat /sys/kernel/debug/kmemleak > unreferenced object 0xffff888105028d80 (size 16): >   comm "kworker/u12:5", pid 359, jiffies 4294902898 (age 1620.144s) >   hex dump (first 16 bytes): >     6d 65 6d 73 74 69 63 6b 30 00 00 00 00 00 00 00 memstick0....... >   backtrace: >     [] slab_post_alloc_hook+0xb2/0x340 >     [] __kmem_cache_alloc_node+0x1bf/0x2c0 >     [] __kmalloc_node_track_caller+0x55/0x160 >     [] kstrdup+0x36/0x60 >     [] kstrdup_const+0x28/0x30 >     [] kvasprintf_const+0x97/0xd0 >     [] kobject_set_name_vargs+0x34/0xc0 >     [] dev_set_name+0x9b/0xd0 >     [] memstick_check+0x181/0x639 [memstick] >     [] process_one_work+0x4e6/0x7e0 >     [] worker_thread+0x76/0x770 >     [] kthread+0x168/0x1a0 >     [] ret_from_fork+0x29/0x50 > [root@pc-mtodorov marvin]# w >  20:27:35 up 27 min,  2 users,  load average: 0.83, 1.15, 1.19 > USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT > marvin   tty2     tty2             20:01   27:10  10:12   2.09s > /opt/google/chrome/chrome --type=utility --utility-sub-type=audio.m > marvin   pts/1    -                20:01    0.00s  2:00   0.38s sudo bash > [root@pc-mtodorov marvin]# uname -rms > Linux 6.1.0-b6bb9676f216-mglru-kmemlk-kasan+ x86_64 > [root@pc-mtodorov marvin]# > > 2. On the Ubuntu 22.10 with Debian build I did not reproduce the error > thus far. > > This looks to me like fixed, but if it doesn't leak anything until > Thursday morning when I will see this desktop box next time, then > we'll know with more certainty. After an inspection in the morning local time and 12:10h uptime, it appears that the problem is fixed. No chrome-triggered i915_gem_mmap_offset_ioctl leaks. By this uptime, there were about 30 instances of leaks in the unpatched kernel. Congratulations! Kind regards, Mirsad -- Mirsad Todorovac System engineer Faculty of Graphic Arts | Academy of Fine Arts University of Zagreb Republic of Croatia, the European Union -- Sistem inženjer Grafički fakultet | Akademija likovnih umjetnosti Sveučilište u Zagrebu