Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3929926pxb; Mon, 1 Feb 2021 08:12:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdj9PkXwTnx+8EYPrP6MC8fQe3uk/xdFW85pYu1RM+qH+js8CwCEdEDQtvb16yMpPhKWpi X-Received: by 2002:aa7:dd12:: with SMTP id i18mr19526561edv.36.1612195928090; Mon, 01 Feb 2021 08:12:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612195928; cv=none; d=google.com; s=arc-20160816; b=ALRO/heasaFZ0fevE3OnJFf0o8AIvCUmCkgy5QLKLdFnCYjFFbCSM0w4Z8dJxA1F7J ybIHLxks/SlKUHdDXVIXQJHSVNa2sTOsgA4X8Y5FYFvoMPw5pIwXzHuaPeiwEXfc+FCt epjpeEI+geOHt+dJVL3NPu8RWcYAb3wzr73FijYjwkUUkcP07Vrk5tICbBF5A5Wyl/9M n3vG/UWQxhFonAO+348HH+CBS87sSpZFd4bjncDO8MH5GevXZJSgw+oQ/Y7GR0rPiC5O aBl5FR8BfVl+Erxz9Y4prgFy21cqyxUrCuBjm8jktBwr9j+8AqHlA25ZHlqfeYuTsuMU YahA== 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=EoTUatjoozboECcDGgxd3SAa7VcaPQT2xVewg6pNNSI=; b=ZmeiY04VEwX6olK9GmFWD/tYRjisT8H4Vifbu9S31jiBgkenrK6ywzRuTa6ZsoxPR0 fILckix5ninIwxklmqaM+REcImwbM1++hUvQjcD/7+gi1dVxPt/JSH21pIgzWlbTyn5a V+vgbfptxbORZMnVYgS20N/dA7bYvyKyJpVuUIqCtfaV6hmlqDKHnVLLrubNXESYyPcw YB0xdinf4ZVapDe+19JIAnny/JzicHYxnDWCG8hg8fIBbCyPJYXkdHLsH9KY+8GId8xL Sv4yCY5TUbwjAxM8zbciGZiQoqU+mj14Z/p2nrNUvjSgFypJhTOQ7fVF1EsNiXOAHwk5 2LJg== 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 gs5si2850933ejb.491.2021.02.01.08.11.41; Mon, 01 Feb 2021 08:12:08 -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 S230013AbhBAQKA (ORCPT + 99 others); Mon, 1 Feb 2021 11:10:00 -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 S229897AbhBAQJ7 (ORCPT ); Mon, 1 Feb 2021 11:09:59 -0500 IronPort-SDR: tmMsnUdcqtrwROFF980siFlweEbpqsLey1zI/KDfDZehQTDjB44ogL+Z7glgTojfaTv4YdETGt 1luX1Wl1sLog== X-IronPort-AV: E=McAfee;i="6000,8403,9882"; a="180784943" X-IronPort-AV: E=Sophos;i="5.79,392,1602572400"; d="scan'208";a="180784943" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 08:08:08 -0800 IronPort-SDR: FSfa88hx+XVDjLrPi1beO/mBqYjz9PlI9D5VFJTwyb1moJVB5HnTYH83Gaptko9FK++MAicn1e 4YEtBYUYaBFg== X-IronPort-AV: E=Sophos;i="5.79,392,1602572400"; d="scan'208";a="479139580" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 08:08:06 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1l6bkB-001Aab-Dc; Mon, 01 Feb 2021 18:08:03 +0200 Date: Mon, 1 Feb 2021 18:08:03 +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: <20210201135251.1884-1-christian.koenig@amd.com> 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 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 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