Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6195856iob; Tue, 10 May 2022 12:32:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD0FnNshHvKXQZbZpQ0pmL81z1uFrAta8Jrh1uJMpb9H25kPBnXSkrM9VobyiMD1FlEx7P X-Received: by 2002:a17:90b:3843:b0:1dc:3da2:7fd8 with SMTP id nl3-20020a17090b384300b001dc3da27fd8mr1376237pjb.219.1652211169820; Tue, 10 May 2022 12:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652211169; cv=none; d=google.com; s=arc-20160816; b=pvpdbUiBNq1lvE6YFqry5UEJkUC9rVtfC3XxWtdz6yY3lsKfEHeNqPd3wHmJQHRiVt Ef2XOTZMmxeZJjJpUyIw0dpvIybrFtI7JLBlLkNuXhRnQ3nKz47FekgFm47BgvWKS57W ge2vAcLuzj7nNoAzsCuJoZ7YqrQuDc/L/pGDvwt0D5xt3xmMQEVZLZQcIGI7b4dfMiqy FRWYVEWzjpOS3qMvicEsI2aVc+2qgM1Os1lhOm3v3qtSImvvYAWkfXlg5ZtSqhQx+XDG CQOEf8NTUaeOL02t3nz8hIIlNMd3l9lbicj6IupxJMiU0omsnlAUtGtxPBPB6PHL6QqK NWzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=VNTPjJNe4QhlHmNu0vSOufo5uC1T4Haoy/RZYBKvTfw=; b=JnbZm1A4A71k7Q/5k34WHCoC4BmJuuZw7A/qTOLPKLuDgzETEz+AwpzXGw3r4B7nEc sa0SO+3f0gLw2zszDSHEcceKgECf9eQQ3gKt1ywe2Nbq65mp/rT7zCYZzCYs/buXIB47 wGha+LxXS4VBcOuK3o8hSu8Ys/6DSJisnn+5mEgpj8U0ug41L1Ko5JVk9bXQBetGDcdo gltWjzOIs9xV1Im2XiA37nrAE4m53uYKlX0rKEFhVs0yJ7agA7DxVEegAMK8OaqqrlLQ FS4/cuPna6F+cLXqnzdSIb7YeI+ZCfg71mZQuMyH17JKQjjyC3aJ8XKoZn0xFoS1cci/ nf+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=KsGr0LnA; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y2-20020a056a001c8200b0050d2a9a54f4si15948814pfw.372.2022.05.10.12.32.32; Tue, 10 May 2022 12:32:49 -0700 (PDT) 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=pass header.i=@aruba.it header.s=a1 header.b=KsGr0LnA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347883AbiEJSRK (ORCPT + 99 others); Tue, 10 May 2022 14:17:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349430AbiEJSQo (ORCPT ); Tue, 10 May 2022 14:16:44 -0400 Received: from smtpcmd13146.aruba.it (smtpcmd13146.aruba.it [62.149.156.146]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F40F7A825 for ; Tue, 10 May 2022 11:12:36 -0700 (PDT) Received: from dfiloni-82ds ([213.215.163.55]) by Aruba Outgoing Smtp with ESMTPSA id oULYnuZc1TRWPoULZnceAZ; Tue, 10 May 2022 20:12:34 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1652206354; bh=tXg3JwEAq3x7kb47JWPESvZY0ObIuCiw9hWWWEOrXEA=; h=Subject:From:To:Date:Content-Type:MIME-Version; b=KsGr0LnAvr/Q7ZDjCUlzh4u1DKoPxDYKniZ5LwAuAhSpa950lhvOIc6f0RBqNed73 JQp6KQrEVUh6ngO/JHjfHDgWodIqdACj3bivaUXcwBSuh6Ll9iT7pCwPDNzTciqX+E Y65gmQEZj6hOfk0PzFmf6d2Ffwdslfy6OxUI/M8jyFQteSRL7IQIHxYZ+OOgZv41kL MKx1268R4TZyhgFe03cF/EvtrNIfa3g/CcIMseMSPxjZg1jW+1Htf1UWU3gPIlkl5i CZonL3/Pm/TNfgA9YFmhBXtEOdrp4AZz6fmw15PSEbSWk4juquUbovXWm/rHdQXaxT 29PalAnv/+uoQ== Message-ID: Subject: Re: [PATCH RESEND 0/2] j1939: make sure that sent DAT/CTL frames are marked as TX From: Devid Antonio Filoni To: Oleksij Rempel Cc: Robin van der Gracht , kernel@pengutronix.de, linux-can@vger.kernel.org, Oleksij Rempel , Oliver Hartkopp , Marc Kleine-Budde , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Maxime Jayat , kbuild test robot , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 10 May 2022 20:12:32 +0200 In-Reply-To: <20220510043406.GB10669@pengutronix.de> References: <20220509170746.29893-1-devid.filoni@egluetechnologies.com> <20220510043406.GB10669@pengutronix.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfFs8gjkPKwq+M5nU/1hYGsZB+Fu5X7eaNMR/Ks5Nn6GXz/kXgxKa9okTnw2l0zl5XYXkNqHN4idPrlLjVKQO9FjAIresmAASSX6lezZRvO/h3OrKaDse Oy9Gu+yhVsRBPsfPr+CUJHioU204vHd79A79Lwx6HwuKPIgkb7z51okeI58PbOlMITkXKohcoww/i6a4l3Z64cFGnFZ9wprUhyu+S2IBR6jczx2dwQ+Q9sKv UTu46SJqNrzD6hamhkXpT6E0EB9d4JLHWx22mefp3A0Dxcl+Yo7CBee/SlYJh/dcC/O54OqR8n92kdrNOEVZvx2oTj1ceC95u/wTcjMgHe+EzsyqCkyt1379 o/PfZBuGtErHGN1aATy9bLtA7/CBUigebEcUTKxeiGiif9DfaHmxCW89gPWCu5TldHvZBL9mzQohUhU957QqUuL68mVnse620qkaOQMeSfubH2+JFqv92agZ G2A3HnqRoYHvXgCF+/XPewHuDInRiw8xHFVlhRRF1ZwqYFTe9MCDmy84xiUteOwFLMaoB5aKCLV339ET6CDY/aOmHA4klpE0LApQFfHNUxVao7N3TNd+4j56 2FaGNnIjpx++ARNrL60byTSr+7dlzdpEnTXFjiZg1JmdzyWF4/IqRFXiA3OzVj0+AmQ= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 Hi Oleksij, On Tue, 2022-05-10 at 06:34 +0200, Oleksij Rempel wrote: > Hi Devid, > > On Mon, May 09, 2022 at 07:07:44PM +0200, Devid Antonio Filoni wrote: > > Hello, > > > > If candump -x is used to dump CAN bus traffic on an interface while a J1939 > > socket is sending multi-packet messages, then the DAT and CTL frames > > show up as RX instead of TX. > > > > This patch series sets to generated struct sk_buff the owning struct sock > > pointer so that the MSG_DONTROUTE flag can be set by recv functions. > > > > I'm not sure that j1939_session_skb_get is needed, I think that session->sk > > could be directly passed as can_skb_set_owner parameter. This patch > > is based on j1939_simple_txnext function which uses j1939_session_skb_get. > > I can provide an additional patch to remove the calls to > > j1939_session_skb_get function if you think they are not needed. > > Thank you for your patches. By testing it I noticed that there is a memory > leak in current kernel and it seems to be even worse after this patches. > Found by this test: > https://github.com/linux-can/can-tests/blob/master/j1939/run_all.sh#L13 > > > Can you please investigate it (or wait until I get time to do it). > > Regards, > Oleksij > I checked the test you linked and I can see that the number of the instances of the can_j1939 module increases on each j1939_ac_100k_dual_can.sh test execution (then the script exits), however this doesn't seem to be worse with my patches, I have the same results with the original kernel. Did you execute a particular test to verify that the memory leak is worse with my patches? I tried to take a look at all code that I changed in my patches but the used ref counters seem to be handled correctly in called functions. I suspected that the issue may be caused by the ref counter increased in can_skb_set_owner() function but, even if I remove that call from the j1939_simple_txnext() function in original kernel, I can still reproduce the memory leak. I think the issue is somewhere else, I'll try to give another look but I can't assure nothing. Best Regards, Devid