Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3951023imu; Mon, 10 Dec 2018 10:24:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/WNFGZClYXAj7gJxBnuS2nP61dQ4BTzf1KILwoQS6g8mQArM4iSmGGAIB6B/YZ62VIOYRLI X-Received: by 2002:a17:902:bd92:: with SMTP id q18mr13175478pls.167.1544466287744; Mon, 10 Dec 2018 10:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544466287; cv=none; d=google.com; s=arc-20160816; b=Xq0TMupJTzyr/qGvn6KsyyzNd7CKfhCCu5+0fAwm02/KSlz7987NHcqzLad5dE4q7v d+HfIDkrWc84qabppPLwYgPjGXKoszCzFrICnhj6rKk5laojldojTaxacKA1j7N4aGH2 O+SXnSvo3L6XFo9171tbmm1RUkanThAVUR7NguIgv/KvOBU6d+y6j7ej8fUuWevz1pli iiiPTJuDG/hQ3Tqb/KYggbEiLBX7/7TRUXOUTbHj4e8r/6XPymA9ZiEfwLGqHH3yZgUp c7jYoVaA8xtV0SVHu3Ws6ZJ8KM1tU+yD/yiGJeZ5Y1oLjjue58nvpRZqB06UfJF7kki0 rH1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=R33d6t46YoRZNT4A5XLKPyM6MDSQzTcQ5HKxL5rHwFs=; b=L/LFK69IVSTqtve+ZfRlgdE72ldzF9NkaDaDL701UuIipryF2K9e93aEMMdVhR/0o5 TQwdo5+A6L/ld3Hk/aEhnS3QcisC8ZpkIyzvrFcRsza29Dp3CeZT3Ao5rhYGgr3TK1wH 9IsFQafUWwu9J1ovm0UaYVckVnvXoF0FFboxVptF5EX5OWCpYBX1r+J34nHQe/W0GGa6 Q9HfKtp/S4BA/wEei8Rc0lJkxxy/tWIybsCE5dWgxruIZeXEeNSor8fBRTIy1U16J45f Pk8a8+nKfz/mYLdrrAAYDKER4MdiNFi93mG4Ff5Y+1cHcRbawFlOYaz7IVpnxE/kfYXf YeVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si10927724pfg.254.2018.12.10.10.24.33; Mon, 10 Dec 2018 10:24:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728961AbeLJSDb (ORCPT + 99 others); Mon, 10 Dec 2018 13:03:31 -0500 Received: from mfb01-md.ns.itscom.net ([175.177.155.109]:39361 "EHLO mfb01-md.ns.itscom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727190AbeLJSDb (ORCPT ); Mon, 10 Dec 2018 13:03:31 -0500 X-Greylist: delayed 412 seconds by postgrey-1.27 at vger.kernel.org; Mon, 10 Dec 2018 13:03:30 EST Received: from mail05-md.ns.itscom.net (mail05-md.ns.itscom.net [175.177.155.115]) by mfb01-md.ns.itscom.net (Postfix) with ESMTP id 55FC5238C21 for ; Tue, 11 Dec 2018 02:56:38 +0900 (JST) Received: from scan26-mds.s.noc.itscom.net (scan26-md.ns.itscom.net [175.177.155.80]) by mail05-md-outgoing.ns.itscom.net (Postfix) with ESMTP id A8374658562; Tue, 11 Dec 2018 02:56:36 +0900 (JST) Received: from unknown (HELO mail04-md-outgoing.ns.itscom.net) ([175.177.155.114]) by scan26-mds.s.noc.itscom.net with ESMTP; 11 Dec 2018 02:56:36 +0900 Received: from jromail.nowhere (h219-110-198-186.catv02.itscom.jp [219.110.198.186]) by mail04-md-outgoing.ns.itscom.net (Postfix) with ESMTP; Tue, 11 Dec 2018 02:56:36 +0900 (JST) Received: from jro by jrobl id 1gWPnI-0000EC-9P ; Tue, 11 Dec 2018 02:56:36 +0900 From: "J. R. Okajima" To: mingo@redhat.com, arjan@linux.intel.com Cc: linux-kernel@vger.kernel.org Subject: Q. re-using lock_classes[] Date: Tue, 11 Dec 2018 02:56:36 +0900 Message-ID: <879.1544464596@jrobl> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, "Troubleshooting" section in Documentation/locking/lockdep-design.txt describes ---------------------------------------- 1. Repeated module loading and unloading while running the validator will result in lock-class leakage. The issue here is that each load of the module will create a new set of lock classes for that module's locks, but module unloading does not remove old classes (see below discussion of reuse of lock classes for why). Therefore, if that module is loaded and unloaded repeatedly, the number of lock classes will eventually reach the maximum. ::: One might argue that the validator should be modified to allow lock classes to be reused. However, if you are tempted to make this argument, first review the code and think through the changes that would be required, keeping in mind that the lock classes to be removed are likely to be linked into the lock-dependency graph. This turns out to be harder to do than to say. ---------------------------------------- I am wondering these "module unloading does not remove old classes" "the lock classes to be removed are likely to be linked into the lock-dependency graph" sentences are still valid? Does "the lock-dependency graph" mean class->hash_entry class->lock_entry and/or list_entries[]? Those are handled by zap_class() at unloading the module. Here is my question. Doesn't zap_class() make the slot in lock_classes[] logically unused? If so, can we re-use the unused slot by searchng and testing some members in struct lock_class? For example, bool test_unused(class) { return !rcu_access_pointer(class->name) && !rcu_access_pointer(class->key) && list_empty(&class->lock_entry) && hlist_unhashed(&class->hash_entry); } Though a new function list_del_init_rcu() for zap_class() will be necessary. J. R. Okajima