Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3931431pxb; Mon, 1 Feb 2021 08:14:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJytoWAkpCHR6wsPp1lZ9TpCyCjMIL3crI6W5/uj69eiHjrlkMTuEVObYARTIC5S4LSOZTBP X-Received: by 2002:a17:906:1d0f:: with SMTP id n15mr17636508ejh.26.1612196046528; Mon, 01 Feb 2021 08:14:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612196046; cv=none; d=google.com; s=arc-20160816; b=Rh/Ca9dRzDv452h3yrrXzc103sf8bIg7NSUBRtHZclc+M4u2YPpysYxeUtEBzCt3ED zTAXVLLx5fJRqe3dyFfTYKCynLDUcOzTRASxEGRBxPBiodhJnVHEvNoQ9gD6WSxsYHxg N5bC6/z0iuoR7JU/wCalFipTQjvCF2hdjN1fw4uU4Xiu/Z7+O2Z13Xp+k9hOBYVwMyN6 66oC6StQy2BnMboKOc6qXrOW/xOqnRyYMZXwThcXECojeTYK5eR4BK1o9tcrggSpiots K1OgWZUhgVcs2zAQI32W+gzXgT+VSkxfXjiXyfggfXS3KmI8wowQN5sIO85ONq3Jgljw M/bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=3G4EPagGIvFpdzBqcFO3lu+GfsAJMBafYkdyMm963gc=; b=iu1IdIiBSGowxrBnim6Ch5nPg6Fa+sRRpufrBRPdKSnlDuKnRZex1hOUD2h8HgzKBt t+9zlnzvzMKM+arQjVg1sqGRP2A7MGvLAyRvEug2wdGStTZTc1mYob9xyHOY7KFTyGOq yzYwdfbEpJmOua5gC5irWLAlhif5YX3FrpcPwsSZp9r2MqtPFHjtG5+Wcxem5v5bmV12 fqXGvjx/jYTYlNKK++snlk3bKg38Sn4NlTMXNNy+lJKiDg4FJB2SKp/3KWUX+nUZIsWA VKovub51+X37Rhn4YF4mRQeT9bglLu6ZnpznxcQPEyXx8UQK+rCnXI1zSXYKSp/X6xad x2ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id md19si10376098ejb.134.2021.02.01.08.13.42; Mon, 01 Feb 2021 08:14:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230256AbhBAQLZ (ORCPT + 99 others); Mon, 1 Feb 2021 11:11:25 -0500 Received: from mga03.intel.com ([134.134.136.65]:9911 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbhBAQLU (ORCPT ); Mon, 1 Feb 2021 11:11:20 -0500 IronPort-SDR: NUU3aRSqGkxpgU1H6AXf3qip81nUsyYRoschso7FMwi06NulteDkN5ybiKuJA+jCpsX9s6JNJx ZJy/pZFbPfpA== X-IronPort-AV: E=McAfee;i="6000,8403,9882"; a="180785402" X-IronPort-AV: E=Sophos;i="5.79,392,1602572400"; d="scan'208";a="180785402" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 08:09:50 -0800 IronPort-SDR: TPSlBngfVN7Lv0pGUgQXv96sHZokfvdn8I6e7X+l8L1XJueVQ0fv+ae8D/DBt+u9bC+u5mZPC2 bxvINMvQABHw== X-IronPort-AV: E=Sophos;i="5.79,392,1602572400"; d="scan'208";a="371598681" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 08:09:48 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1l6blp-001Ac3-93; Mon, 01 Feb 2021 18:09:45 +0200 Date: Mon, 1 Feb 2021 18:09:45 +0200 From: Andy Shevchenko To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: mojha@codeaurora.org, jkosina@suse.cz, cezary.rojewski@intel.com, neilb@suse.com, b00073877@aus.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH] list: add more extensive double add check Message-ID: References: <20210201135251.1884-1-christian.koenig@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 01, 2021 at 06:08:03PM +0200, Andy Shevchenko wrote: > On Mon, Feb 01, 2021 at 02:52:51PM +0100, Christian K?nig wrote: > > Adding the same element to a linked list multiple times > > seems to be a rather common programming mistake. To debug > > those I've more than once written some code to check a > > linked list for duplicates. > > > > Since re-inventing the wheel over and over again is a bad > > idea this patch tries to add some common code which allows > > to check linked lists for duplicates while adding new > > elements. > > > > When list debugging is enabled we currently already check > > the previous and next element if they are identical to the > > new one. This patch now adds a configuration option to > > check N elements before and after the desired position. > > > > By default we still only test one item since testing more > > means quite a large CPU overhead. This can be overwritten > > on a per C file bases by defining DEBUG_LIST_DOUBLE_ADD > > before including list.h. > > I'm not sure it is a good idea. Currently the implementation is *generic*. > You are customizing it w/o letting caller know. > > Create a derivative implementation and name it exlist (exclusive list) and use > whenever it makes sense. And make depth is a runtime parameter available for user. > And I think if you are still pushing to modify generic one the default must be > 0 in order not altering current behaviour. > > > A new kunit test is also added to the existing list tests > > which intentionally triggers the debug functionality. -- With Best Regards, Andy Shevchenko