Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5004128rwb; Wed, 21 Sep 2022 01:35:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5kxP69KcSvBOrDf17LRZJ/coCKU4HAQVtSf/GLRn1zeHUVNFs//0cXo6LZe4lFPb4Tu5BZ X-Received: by 2002:a17:902:a388:b0:176:e571:4923 with SMTP id x8-20020a170902a38800b00176e5714923mr3665508pla.6.1663749347604; Wed, 21 Sep 2022 01:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663749347; cv=none; d=google.com; s=arc-20160816; b=IiHcjYJaKo0Q2OpWKpcW6rb1XAw11HqaV9UFzDS2vZxQXztHcwT4+qWjRkuOE7JJwK g9TT8YtrTDNc1YI080ExYO9/zLWAhiYuK5MuwBYgwRpzk3U6OzvbKuYLbLWO51JG+daS 4RIZL4AeQnwOjB7kqgn/iT/P78mLppgx1o0LUW7IjJYiCZ5N5Y8KBH7IvNjxaerhHd29 ai++BLCvvEU1brMB/11ABnznKMT425Lhxeey8Yksd4pvz2E3QI20Yu+/G/3+8fd0Pm+a v3yYgMywyQjMVATvJvdUKIhlQXRCptDNYg/TwjpouJaPthjEjdSJrTIbX+iOvxnkrJp/ 8/RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=LdfLsQzbDkIurGyxKIpF+YTKTJf6SRMX4DwgzZoBHWg=; b=ikR/XaN26H+oLOMwBkuv+CprUqYuIeH3IOmESVbj1aShOvlnZHjOZoucd9qrW97vmu 1XMMKEifUdpMZqpYP94BczC6aX5wcAqnTi7kibRAtUaSg90eAd1G9YV4ojiCPOVZehax Kee0XsXaukKhKK5eqEcPHjR5qaQZLDNMVcaTV1svmA9/dQXHvdDgdPNYAR+wuNjwioio mjA6V3m21FexQBRunzLVifNXnIXHN4+dHdwubu3Ri3RF8u9WrXTSh78G/+1yiAviPHfv cBfo8w34sp1nAdjCsFy0CeH9018vACX0KpRo8dxP1nxWYpqLQDj/j7LquHaM51TKmKBv MvJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OOKFH6VV; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a170903228d00b0016d9d416df3si2203318plh.574.2022.09.21.01.35.35; Wed, 21 Sep 2022 01:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@gmail.com header.s=20210112 header.b=OOKFH6VV; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230149AbiIUIbs (ORCPT + 63 others); Wed, 21 Sep 2022 04:31:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230270AbiIUIbn (ORCPT ); Wed, 21 Sep 2022 04:31:43 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C3377EFD3 for ; Wed, 21 Sep 2022 01:31:41 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id r13-20020a056830418d00b0065601df69c0so3430592otu.7 for ; Wed, 21 Sep 2022 01:31:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=LdfLsQzbDkIurGyxKIpF+YTKTJf6SRMX4DwgzZoBHWg=; b=OOKFH6VV4PfkT7wuvUJ4ouAYu4MuMTpMelF5fH2R3tS0lGACNxaefTqN2zt4Vk7VqM eLh7ktRefZORHQkG0dK53HszfEzKRjURSqTKmAEu7bGsjP4KRLoDxIcPXQToRzJrNmDG 7WGntKGbOtY74r034pZGjERtqkJuk7HEwZK7Hm5RmPA1RG2x3mXxNobiiUohqjktbyH5 2NcUiIuZ5BeKUZPZw45ewpbnhGiJqACG22O+DbiihntgBN75k6VifWc8TKBJWQ3kMoE7 jwgWiAsYDNzK95zfAObnTccQW4RvOuv5tIpBrOTl7BJ3smPmNpDLV6g9NmiV7hgCtBU5 OsBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=LdfLsQzbDkIurGyxKIpF+YTKTJf6SRMX4DwgzZoBHWg=; b=CvgnqypQbb0fmXU86UDufLmo42qY2wPBDMmdfet6ciMGBAlRSNNGRSXwkrXlFDtws0 QNyxX7+tyrSAlzv13OTsO+ecWTXrcKNILlKMVgumM+aLdYDjeRgE/M/8nxIJPlccy10I if1xut70NE8HGgSgoOEat6GBlPbJZ6Awx3JX5A9GB2iI9dxfT2WEWmY0o3u5pE7A9lb7 CqLkqxBqJihKydW4x7gytN7dX+7bS3dkQosyFC9gesv+9x/mQpHxt5lDmZOcvvP12SL7 qnxlWm8uT6Xw3ZNENcE5ikaUnOCNoLgiXFkg6w0b4T0ytHaqX8b0WMXMDXggWCPc2Tmj 9xmg== X-Gm-Message-State: ACrzQf2yR0jGvsPRDkaIUojVME6lrZUOemZT2tdRLqjZsTCvV26Ps5vg Y0yUIYUVW+11iIKXDkISxZOeE6EBoxAWC0xPrzssH6ba7z8= X-Received: by 2002:a05:6830:3910:b0:656:3fb5:e600 with SMTP id br16-20020a056830391000b006563fb5e600mr11968617otb.173.1663749100265; Wed, 21 Sep 2022 01:31:40 -0700 (PDT) MIME-Version: 1.0 References: <20220915043527.737133-1-venkatch@gmail.com> <238a21a8-c97b-5a38-6c08-9057055bf73f@nbd.name> <9acc4159-8223-bbca-a83f-d075660ac6db@nbd.name> <4040f674-8430-69ba-1b6f-f9fd92da413d@nbd.name> In-Reply-To: <4040f674-8430-69ba-1b6f-f9fd92da413d@nbd.name> From: Venkat Ch Date: Wed, 21 Sep 2022 14:01:29 +0530 Message-ID: Subject: Re: [PATCH v2] wifi: mac80211: Fix performance issue with mutex_lock To: Felix Fietkau Cc: johannes@sipsolutions.net, linux-wireless@vger.kernel.org, Venkat Chimata Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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-wireless@vger.kernel.org Hi Felix, Thanks again for patiently discussing things. I clearly understand what you said about locks. Now that we know the background of the problem, do you suggest any potential solution or any potential direction that I should start investigating? Please let me know. Thanks & Regards Venkat On Wed, 21 Sept 2022 at 13:35, Felix Fietkau wrote: > > > On 20.09.22 21:23, Venkat Ch wrote: > > Hi Felix, > > > > Following is the background of the problem, how I traced to > > mutex_lock and why I propose rcu locks. > > > > Issue: > > On a 10Mbps upload / 50 Mbps download connection, the following issue reported. > > > > Video periodically freezes and/or appears delayed when on Zoom or Teams. > > 1. Video will freeze for 10 or 15 seconds periodically when on a call, > > but audio continues and the session doesn't drop. > > 2. The video still works but it appears delay (I move, but the video > > of my movement is noticeably delay by a second or so) > > > > Tracing to mutex_lock(sta_mutex): > > > > When I investigated, I found that the ucentral agent in openwifi > > fetches the station list periodically. Without the station list > > fetch, the video quality is just fine. I investigated the station list > > path and found this mutex_lock. I also see that earlier it was > > rcu_lock which protected the station list in this path. In this > > commit, https://github.com/torvalds/linux/commit/66572cfc30a4b764150c83ee5d842a3ce17991c9, > > rcu lock was changed to mutex lock without providing any reason. > The reason seems clear to me, even though it was not explicitly stated > in the commit message: in sta_set_sinfo it introduces a call to a driver > op that is allowed to sleep. > > > I also saw this comment just above the sta_mutex declaration. > > /* Station data */ > > /* > > * The mutex only protects the list, hash table and > > * counter, reads are done with RCU. > > */ > > struct mutex sta_mtx; > > > > So I reverted back the mutex_lock with rcu_lock and it just worked > > fine. We tested for more than 2 weeks before concluding this analysis. > > > > I think the usage of mutex_lock is impacting the tx / rx path > > somewhere and hence the issue. It is a challenge to trace the exact > > function though. > > I don't see any critical part in the tx/rx path which depends on the > sta_mtx lock. My guess is that for some reason your change is simply > accidentally papering over the real bug, which may be somewhere else > entirely, maybe even in the driver. A freeze for 10-15 seconds > definitely does not sound like simple lock contention on the mutex, > since a single station dump will be much faster than that. > > - Felix -- If you rest, you rust