Message ID | 20221122153516.52577-1-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2283127wrr; Tue, 22 Nov 2022 07:38:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf7BkQ4g0gQ3Ulc5volrX7QbXyUvr87JsW9Wo2CJMDXtrbBcmIGPpOc4GrAue7F/WGgdIw5G X-Received: by 2002:a17:906:19d7:b0:7b2:b782:e1df with SMTP id h23-20020a17090619d700b007b2b782e1dfmr16126814ejd.308.1669131520410; Tue, 22 Nov 2022 07:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669131520; cv=none; d=google.com; s=arc-20160816; b=H/7/r8GU1QpQ5GRpAFy2WkXsXik0OEroMOXb91vUGPExe6X4+K6NNZScM4fvXhTzXu qbCQ1nBwGUibgHWmCWZhyzLQiTcbDfBbtuQCeYEYnL72zOdD2DIiKm0yiVa7rEu4vJWd 6vaIptyNw7VyWIX4uwot9/sit7vsQCa0YD3Gw8xEFBsImcq+A6KU9y3ZxyQZ2/YXQHRt Ij+u2AvTCbe2NOtX3XG3zeAV0bGqtaiSfh/Gb4LnqFIeyiL0RS22qEL/4jd6VaMBAGaE n9O7/2aS8WGQNW3BDhGmIodVXXFvzsvTNN+YsbJ0ctf4VDR4BSe8i3Afrxwx6Xzdw+fY RtPw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=1Qtx7ZlRqQzibs+Sjim2+WzP1E23CpTGh86NOik24JI=; b=N2AeY5bmdVgl+f8hAvcbvOH1dqlAeVmRM0kjUBO9OgG5z9PuYCKJ115Ad9PBX9AQ8t vdn0878DCrVsDdly42eEzP5xSxCwkghUEcL9a/MkR7/+x74935dVCmZ/ABF1AMVy8qWZ BjxiFKKaDwMXiTBubTKtuvmiSk8kGOA7+1FoyA1bIaPPV6Aw9CirkSs7pM7Wa7tGPphH BWdm6f+M1mZGVuttIzbe61dNEw7u4+NvaYNf5wEDRBytv4GBBBQQ3TMXkSs1NV+sgpjY VzQbktF56/pg/r8rCXguR9g7RSTAmmCiAQpDh5ubjbUS2Z0f125LJ0XdvOGKUhMNllg8 9yMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mC07Z9IL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds6-20020a0564021cc600b0045c26f0050esi11974208edb.238.2022.11.22.07.38.16; Tue, 22 Nov 2022 07:38:40 -0800 (PST) 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=@intel.com header.s=Intel header.b=mC07Z9IL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232763AbiKVPfZ (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Tue, 22 Nov 2022 10:35:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232723AbiKVPfP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 22 Nov 2022 10:35:15 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27620682B7; Tue, 22 Nov 2022 07:35:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669131315; x=1700667315; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Lk7Aa8ZXFKY55rSbLTJ7BLbpsyJEXtHLhmH5NxdPyRU=; b=mC07Z9ILSsILE0OlTdG+lBfblmmeYu5gBo/4SHNITVYWO/TrUvIxOQAc h9x95sEG+FIb7k/EThUmyQ+KAlLPcmHUeQoOgGDbGfMZF8l4npn8ecCpV 4I/hVw8Yp63v6XN2niZ3Zp56OsjuaqnL1KoUm/pQimqdxbKGrQT2me0yS /GeQA152JcCrSG0/f0hwVPTFIaabgMacbTQKTK2I9bXCtJzzVp4SsOjTd wlvK8O8mBuo87PI0ZWX1hsAo+2UvUT5NaebahCvTmSusGZrKfhFOJPu/k +YrMv1mLQ/Z8pacPBCkxoPjXOLrjgmIoqtjaerf6wvYTYWcKLkYAdfzLT A==; X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="315662399" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="315662399" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2022 07:35:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="730435563" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="730435563" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 22 Nov 2022 07:35:00 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4560E128; Tue, 22 Nov 2022 17:35:26 +0200 (EET) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Jakob Koschel <jakobkoschel@gmail.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Mathias Nyman <mathias.nyman@linux.intel.com>, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Jani Nikula <jani.nikula@linux.intel.com>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Kevin Cernekee <cernekee@gmail.com>, Mathias Nyman <mathias.nyman@intel.com>, Hans de Goede <hdegoede@redhat.com>, Jani Nikula <jani.nikula@intel.com> Subject: [PATCH v3 1/4] i915: Move list_count() to list.h for broader use Date: Tue, 22 Nov 2022 17:35:13 +0200 Message-Id: <20221122153516.52577-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750211253140519629?= X-GMAIL-MSGID: =?utf-8?q?1750211253140519629?= |
Series |
[v3,1/4] i915: Move list_count() to list.h for broader use
|
|
Commit Message
Andy Shevchenko
Nov. 22, 2022, 3:35 p.m. UTC
Some of the existing users, and definitely will be new ones, want to count existing nodes in the list. Provide a generic API for that by moving code from i915 to list.h. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jani Nikula <jani.nikula@intel.com> --- v3: added tag (Jani), changed to be static inline (Mike) v2: dropped the duplicate code in i915 (LKP) drivers/gpu/drm/i915/gt/intel_engine_cs.c | 13 +------------ include/linux/list.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 12 deletions(-)
Comments
On Tue, Nov 22, 2022 at 05:35:13PM +0200, Andy Shevchenko wrote: > Some of the existing users, and definitely will be new ones, want to > count existing nodes in the list. Provide a generic API for that by > moving code from i915 to list.h. Sorry for the noise, forgot to squash one part, so it get's not compilable.
Hi Andy, I love your patch! Yet something to improve: [auto build test ERROR on usb/usb-testing] [also build test ERROR on usb/usb-next usb/usb-linus drm-intel/for-linux-next drm-intel/for-linux-next-fixes linus/master v6.1-rc6 next-20221122] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i915-Move-list_count-to-list-h-for-broader-use/20221122-233657 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing patch link: https://lore.kernel.org/r/20221122153516.52577-1-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v3 1/4] i915: Move list_count() to list.h for broader use config: um-i386_defconfig compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/3d217ef769536f160f5c20224aeb0f9070bdfdcf git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Andy-Shevchenko/i915-Move-list_count-to-list-h-for-broader-use/20221122-233657 git checkout 3d217ef769536f160f5c20224aeb0f9070bdfdcf # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): ld: fs/isofs/inode.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/isofs/namei.o:include/linux/list.h:663: first defined here ld: fs/isofs/dir.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/isofs/namei.o:include/linux/list.h:663: first defined here ld: fs/isofs/util.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/isofs/namei.o:include/linux/list.h:663: first defined here ld: fs/isofs/rock.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/isofs/namei.o:include/linux/list.h:663: first defined here ld: fs/isofs/export.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/isofs/namei.o:include/linux/list.h:663: first defined here ld: fs/isofs/joliet.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/isofs/namei.o:include/linux/list.h:663: first defined here -- ld: fs/autofs/inode.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/autofs/init.o:include/linux/list.h:663: first defined here ld: fs/autofs/root.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/autofs/init.o:include/linux/list.h:663: first defined here ld: fs/autofs/symlink.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/autofs/init.o:include/linux/list.h:663: first defined here ld: fs/autofs/waitq.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/autofs/init.o:include/linux/list.h:663: first defined here ld: fs/autofs/expire.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/autofs/init.o:include/linux/list.h:663: first defined here ld: fs/autofs/dev-ioctl.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; fs/autofs/init.o:include/linux/list.h:663: first defined here -- ld: block/bfq-wf2q.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; block/bfq-iosched.o:include/linux/list.h:663: first defined here ld: block/bfq-cgroup.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; block/bfq-iosched.o:include/linux/list.h:663: first defined here vim +663 include/linux/list.h 557 558 /** 559 * list_next_entry - get the next element in list 560 * @pos: the type * to cursor 561 * @member: the name of the list_head within the struct. 562 */ 563 #define list_next_entry(pos, member) \ 564 list_entry((pos)->member.next, typeof(*(pos)), member) 565 566 /** 567 * list_next_entry_circular - get the next element in list 568 * @pos: the type * to cursor. 569 * @head: the list head to take the element from. 570 * @member: the name of the list_head within the struct. 571 * 572 * Wraparound if pos is the last element (return the first element). 573 * Note, that list is expected to be not empty. 574 */ 575 #define list_next_entry_circular(pos, head, member) \ 576 (list_is_last(&(pos)->member, head) ? \ 577 list_first_entry(head, typeof(*(pos)), member) : list_next_entry(pos, member)) 578 579 /** 580 * list_prev_entry - get the prev element in list 581 * @pos: the type * to cursor 582 * @member: the name of the list_head within the struct. 583 */ 584 #define list_prev_entry(pos, member) \ 585 list_entry((pos)->member.prev, typeof(*(pos)), member) 586 587 /** 588 * list_prev_entry_circular - get the prev element in list 589 * @pos: the type * to cursor. 590 * @head: the list head to take the element from. 591 * @member: the name of the list_head within the struct. 592 * 593 * Wraparound if pos is the first element (return the last element). 594 * Note, that list is expected to be not empty. 595 */ 596 #define list_prev_entry_circular(pos, head, member) \ 597 (list_is_first(&(pos)->member, head) ? \ 598 list_last_entry(head, typeof(*(pos)), member) : list_prev_entry(pos, member)) 599 600 /** 601 * list_for_each - iterate over a list 602 * @pos: the &struct list_head to use as a loop cursor. 603 * @head: the head for your list. 604 */ 605 #define list_for_each(pos, head) \ 606 for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) 607 608 /** 609 * list_for_each_rcu - Iterate over a list in an RCU-safe fashion 610 * @pos: the &struct list_head to use as a loop cursor. 611 * @head: the head for your list. 612 */ 613 #define list_for_each_rcu(pos, head) \ 614 for (pos = rcu_dereference((head)->next); \ 615 !list_is_head(pos, (head)); \ 616 pos = rcu_dereference(pos->next)) 617 618 /** 619 * list_for_each_continue - continue iteration over a list 620 * @pos: the &struct list_head to use as a loop cursor. 621 * @head: the head for your list. 622 * 623 * Continue to iterate over a list, continuing after the current position. 624 */ 625 #define list_for_each_continue(pos, head) \ 626 for (pos = pos->next; !list_is_head(pos, (head)); pos = pos->next) 627 628 /** 629 * list_for_each_prev - iterate over a list backwards 630 * @pos: the &struct list_head to use as a loop cursor. 631 * @head: the head for your list. 632 */ 633 #define list_for_each_prev(pos, head) \ 634 for (pos = (head)->prev; !list_is_head(pos, (head)); pos = pos->prev) 635 636 /** 637 * list_for_each_safe - iterate over a list safe against removal of list entry 638 * @pos: the &struct list_head to use as a loop cursor. 639 * @n: another &struct list_head to use as temporary storage 640 * @head: the head for your list. 641 */ 642 #define list_for_each_safe(pos, n, head) \ 643 for (pos = (head)->next, n = pos->next; \ 644 !list_is_head(pos, (head)); \ 645 pos = n, n = pos->next) 646 647 /** 648 * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry 649 * @pos: the &struct list_head to use as a loop cursor. 650 * @n: another &struct list_head to use as temporary storage 651 * @head: the head for your list. 652 */ 653 #define list_for_each_prev_safe(pos, n, head) \ 654 for (pos = (head)->prev, n = pos->prev; \ 655 !list_is_head(pos, (head)); \ 656 pos = n, n = pos->prev) 657 658 /** 659 * list_count - count nodes in the list 660 * @head: the head for your list. 661 */ 662 size_t list_count(struct list_head *head) > 663 { 664 struct list_head *pos; 665 size_t count = 0; 666 667 list_for_each(pos, head) 668 count++; 669 670 return count; 671 } 672
Hi Andy, I love your patch! Yet something to improve: [auto build test ERROR on usb/usb-testing] [also build test ERROR on usb/usb-next usb/usb-linus drm-intel/for-linux-next drm-intel/for-linux-next-fixes linus/master v6.1-rc6 next-20221122] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i915-Move-list_count-to-list-h-for-broader-use/20221122-233657 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing patch link: https://lore.kernel.org/r/20221122153516.52577-1-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v3 1/4] i915: Move list_count() to list.h for broader use config: s390-defconfig compiler: s390-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/3d217ef769536f160f5c20224aeb0f9070bdfdcf git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Andy-Shevchenko/i915-Move-list_count-to-list-h-for-broader-use/20221122-233657 git checkout 3d217ef769536f160f5c20224aeb0f9070bdfdcf # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=s390 prepare If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr] scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr] scripts/genksyms/parse.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples In file included from include/linux/preempt.h:11, from include/linux/percpu.h:6, from include/linux/context_tracking_state.h:5, from include/linux/hardirq.h:5, from include/linux/kvm_host.h:7, from arch/s390/kernel/asm-offsets.c:11: include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ In file included from include/linux/preempt.h:11, from arch/s390/include/asm/timex.h:13, from arch/s390/kernel/vdso64/getcpu.c:6: include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ In file included from include/linux/rculist.h:10, from include/linux/pid.h:5, from include/linux/sched.h:14, from arch/s390/include/asm/syscall.h:13, from arch/s390/include/asm/vdso/gettimeofday.h:9, from include/vdso/datapage.h:137, from arch/s390/kernel/vdso64/../../../../lib/vdso/gettimeofday.c:5, from arch/s390/kernel/vdso64/vdso64_generic.c:2: include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ s390-linux-ld: arch/s390/kernel/vdso64/getcpu.o: in function `list_count': >> include/linux/list.h:663: multiple definition of `list_count'; arch/s390/kernel/vdso64/vdso64_generic.o:include/linux/list.h:663: first defined here make[2]: *** [arch/s390/kernel/vdso64/Makefile:50: arch/s390/kernel/vdso64/vdso64.so.dbg] Error 1 make[2]: Target 'include/generated/vdso64-offsets.h' not remade because of errors. make[1]: *** [arch/s390/Makefile:159: vdso_prepare] Error 2 make[1]: Target 'prepare' not remade because of errors. make: *** [Makefile:231: __sub-make] Error 2 make: Target 'prepare' not remade because of errors. vim +663 include/linux/list.h 557 558 /** 559 * list_next_entry - get the next element in list 560 * @pos: the type * to cursor 561 * @member: the name of the list_head within the struct. 562 */ 563 #define list_next_entry(pos, member) \ 564 list_entry((pos)->member.next, typeof(*(pos)), member) 565 566 /** 567 * list_next_entry_circular - get the next element in list 568 * @pos: the type * to cursor. 569 * @head: the list head to take the element from. 570 * @member: the name of the list_head within the struct. 571 * 572 * Wraparound if pos is the last element (return the first element). 573 * Note, that list is expected to be not empty. 574 */ 575 #define list_next_entry_circular(pos, head, member) \ 576 (list_is_last(&(pos)->member, head) ? \ 577 list_first_entry(head, typeof(*(pos)), member) : list_next_entry(pos, member)) 578 579 /** 580 * list_prev_entry - get the prev element in list 581 * @pos: the type * to cursor 582 * @member: the name of the list_head within the struct. 583 */ 584 #define list_prev_entry(pos, member) \ 585 list_entry((pos)->member.prev, typeof(*(pos)), member) 586 587 /** 588 * list_prev_entry_circular - get the prev element in list 589 * @pos: the type * to cursor. 590 * @head: the list head to take the element from. 591 * @member: the name of the list_head within the struct. 592 * 593 * Wraparound if pos is the first element (return the last element). 594 * Note, that list is expected to be not empty. 595 */ 596 #define list_prev_entry_circular(pos, head, member) \ 597 (list_is_first(&(pos)->member, head) ? \ 598 list_last_entry(head, typeof(*(pos)), member) : list_prev_entry(pos, member)) 599 600 /** 601 * list_for_each - iterate over a list 602 * @pos: the &struct list_head to use as a loop cursor. 603 * @head: the head for your list. 604 */ 605 #define list_for_each(pos, head) \ 606 for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) 607 608 /** 609 * list_for_each_rcu - Iterate over a list in an RCU-safe fashion 610 * @pos: the &struct list_head to use as a loop cursor. 611 * @head: the head for your list. 612 */ 613 #define list_for_each_rcu(pos, head) \ 614 for (pos = rcu_dereference((head)->next); \ 615 !list_is_head(pos, (head)); \ 616 pos = rcu_dereference(pos->next)) 617 618 /** 619 * list_for_each_continue - continue iteration over a list 620 * @pos: the &struct list_head to use as a loop cursor. 621 * @head: the head for your list. 622 * 623 * Continue to iterate over a list, continuing after the current position. 624 */ 625 #define list_for_each_continue(pos, head) \ 626 for (pos = pos->next; !list_is_head(pos, (head)); pos = pos->next) 627 628 /** 629 * list_for_each_prev - iterate over a list backwards 630 * @pos: the &struct list_head to use as a loop cursor. 631 * @head: the head for your list. 632 */ 633 #define list_for_each_prev(pos, head) \ 634 for (pos = (head)->prev; !list_is_head(pos, (head)); pos = pos->prev) 635 636 /** 637 * list_for_each_safe - iterate over a list safe against removal of list entry 638 * @pos: the &struct list_head to use as a loop cursor. 639 * @n: another &struct list_head to use as temporary storage 640 * @head: the head for your list. 641 */ 642 #define list_for_each_safe(pos, n, head) \ 643 for (pos = (head)->next, n = pos->next; \ 644 !list_is_head(pos, (head)); \ 645 pos = n, n = pos->next) 646 647 /** 648 * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry 649 * @pos: the &struct list_head to use as a loop cursor. 650 * @n: another &struct list_head to use as temporary storage 651 * @head: the head for your list. 652 */ 653 #define list_for_each_prev_safe(pos, n, head) \ 654 for (pos = (head)->prev, n = pos->prev; \ 655 !list_is_head(pos, (head)); \ 656 pos = n, n = pos->prev) 657 658 /** 659 * list_count - count nodes in the list 660 * @head: the head for your list. 661 */ 662 size_t list_count(struct list_head *head) > 663 { 664 struct list_head *pos; 665 size_t count = 0; 666 667 list_for_each(pos, head) 668 count++; 669 670 return count; 671 } 672
Hi Andy, I love your patch! Perhaps something to improve: [auto build test WARNING on usb/usb-testing] [also build test WARNING on usb/usb-next usb/usb-linus drm-intel/for-linux-next drm-intel/for-linux-next-fixes linus/master v6.1-rc6 next-20221122] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i915-Move-list_count-to-list-h-for-broader-use/20221122-233657 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing patch link: https://lore.kernel.org/r/20221122153516.52577-1-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v3 1/4] i915: Move list_count() to list.h for broader use config: m68k-allyesconfig compiler: m68k-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/3d217ef769536f160f5c20224aeb0f9070bdfdcf git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Andy-Shevchenko/i915-Move-list_count-to-list-h-for-broader-use/20221122-233657 git checkout 3d217ef769536f160f5c20224aeb0f9070bdfdcf # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k prepare If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): In file included from include/linux/rculist.h:10, from include/linux/pid.h:5, from include/linux/sched.h:14, from arch/m68k/kernel/asm-offsets.c:15: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ -- In file included from include/linux/rculist.h:10, from include/linux/pid.h:5, from include/linux/sched.h:14, from arch/m68k/kernel/ptrace.c:14: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ arch/m68k/kernel/ptrace.c:275:16: warning: no previous prototype for 'syscall_trace_enter' [-Wmissing-prototypes] 275 | asmlinkage int syscall_trace_enter(void) | ^~~~~~~~~~~~~~~~~~~ arch/m68k/kernel/ptrace.c:284:17: warning: no previous prototype for 'syscall_trace_leave' [-Wmissing-prototypes] 284 | asmlinkage void syscall_trace_leave(void) | ^~~~~~~~~~~~~~~~~~~ -- In file included from include/linux/preempt.h:11, from include/linux/spinlock.h:56, from include/linux/mmzone.h:8, from include/linux/gfp.h:7, from include/linux/mm.h:7, from arch/m68k/kernel/setup_mm.c:13, from arch/m68k/kernel/setup.c:3: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ arch/m68k/kernel/setup_mm.c:507:6: warning: no previous prototype for 'check_bugs' [-Wmissing-prototypes] 507 | void check_bugs(void) | ^~~~~~~~~~ -- In file included from include/linux/rculist.h:10, from include/linux/pid.h:5, from include/linux/sched.h:14, from arch/m68k/kernel/signal.c:31: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ arch/m68k/kernel/signal.c:756:18: warning: no previous prototype for 'do_sigreturn' [-Wmissing-prototypes] 756 | asmlinkage void *do_sigreturn(struct pt_regs *regs, struct switch_stack *sw) | ^~~~~~~~~~~~ arch/m68k/kernel/signal.c:783:18: warning: no previous prototype for 'do_rt_sigreturn' [-Wmissing-prototypes] 783 | asmlinkage void *do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw) | ^~~~~~~~~~~~~~~ arch/m68k/kernel/signal.c:1106:6: warning: no previous prototype for 'do_notify_resume' [-Wmissing-prototypes] 1106 | void do_notify_resume(struct pt_regs *regs) | ^~~~~~~~~~~~~~~~ -- In file included from include/linux/rculist.h:10, from include/linux/pid.h:5, from include/linux/sched.h:14, from arch/m68k/kernel/sys_m68k.c:12: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ arch/m68k/kernel/sys_m68k.c:40:17: warning: no previous prototype for 'sys_mmap2' [-Wmissing-prototypes] 40 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | ^~~~~~~~~ arch/m68k/kernel/sys_m68k.c:378:1: warning: no previous prototype for 'sys_cacheflush' [-Wmissing-prototypes] 378 | sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len) | ^~~~~~~~~~~~~~ arch/m68k/kernel/sys_m68k.c:463:1: warning: no previous prototype for 'sys_atomic_cmpxchg_32' [-Wmissing-prototypes] 463 | sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5, | ^~~~~~~~~~~~~~~~~~~~~ arch/m68k/kernel/sys_m68k.c:562:16: warning: no previous prototype for 'sys_getpagesize' [-Wmissing-prototypes] 562 | asmlinkage int sys_getpagesize(void) | ^~~~~~~~~~~~~~~ arch/m68k/kernel/sys_m68k.c:567:26: warning: no previous prototype for 'sys_get_thread_area' [-Wmissing-prototypes] 567 | asmlinkage unsigned long sys_get_thread_area(void) | ^~~~~~~~~~~~~~~~~~~ arch/m68k/kernel/sys_m68k.c:572:16: warning: no previous prototype for 'sys_set_thread_area' [-Wmissing-prototypes] 572 | asmlinkage int sys_set_thread_area(unsigned long tp) | ^~~~~~~~~~~~~~~~~~~ arch/m68k/kernel/sys_m68k.c:578:16: warning: no previous prototype for 'sys_atomic_barrier' [-Wmissing-prototypes] 578 | asmlinkage int sys_atomic_barrier(void) | ^~~~~~~~~~~~~~~~~~ -- In file included from include/linux/module.h:12, from arch/m68k/kernel/time.c:16: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ arch/m68k/kernel/time.c:154:13: warning: no previous prototype for 'time_init' [-Wmissing-prototypes] 154 | void __init time_init(void) | ^~~~~~~~~ -- In file included from include/linux/rculist.h:10, from include/linux/pid.h:5, from include/linux/sched.h:14, from arch/m68k/kernel/traps.c:21: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ arch/m68k/kernel/traps.c:752:17: warning: no previous prototype for 'buserr_c' [-Wmissing-prototypes] 752 | asmlinkage void buserr_c(struct frame *fp) | ^~~~~~~~ arch/m68k/kernel/traps.c:966:6: warning: no previous prototype for 'bad_super_trap' [-Wmissing-prototypes] 966 | void bad_super_trap (struct frame *fp) | ^~~~~~~~~~~~~~ arch/m68k/kernel/traps.c:1138:17: warning: no previous prototype for 'set_esp0' [-Wmissing-prototypes] 1138 | asmlinkage void set_esp0(unsigned long ssp) | ^~~~~~~~ arch/m68k/kernel/traps.c:1147:17: warning: no previous prototype for 'fpsp040_die' [-Wmissing-prototypes] 1147 | asmlinkage void fpsp040_die(void) | ^~~~~~~~~~~ arch/m68k/kernel/traps.c:1153:17: warning: no previous prototype for 'fpemu_signal' [-Wmissing-prototypes] 1153 | asmlinkage void fpemu_signal(int signal, int code, void *addr) | ^~~~~~~~~~~~ -- In file included from include/linux/module.h:12, from arch/m68k/kernel/ints.c:9: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ arch/m68k/kernel/ints.c:57:13: warning: no previous prototype for 'init_IRQ' [-Wmissing-prototypes] 57 | void __init init_IRQ(void) | ^~~~~~~~ arch/m68k/kernel/ints.c:165:17: warning: no previous prototype for 'handle_badint' [-Wmissing-prototypes] 165 | asmlinkage void handle_badint(struct pt_regs *regs) | ^~~~~~~~~~~~~ -- In file included from include/linux/rculist.h:10, from include/linux/pid.h:5, from include/linux/sched.h:14, from arch/m68k/kernel/vectors.c:20: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ arch/m68k/kernel/vectors.c:51:13: warning: no previous prototype for 'base_trap_init' [-Wmissing-prototypes] 51 | void __init base_trap_init(void) | ^~~~~~~~~~~~~~ arch/m68k/kernel/vectors.c:74:13: warning: no previous prototype for 'trap_init' [-Wmissing-prototypes] 74 | void __init trap_init (void) | ^~~~~~~~~ -- In file included from include/linux/rculist.h:10, from include/linux/pid.h:5, from include/linux/sched.h:14, from include/linux/sched/task_stack.h:9, from include/linux/elfcore.h:7, from include/linux/crash_core.h:6, from include/linux/kexec.h:18, from arch/m68k/kernel/machine_kexec.c:6: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ arch/m68k/kernel/machine_kexec.c:26:6: warning: no previous prototype for 'machine_shutdown' [-Wmissing-prototypes] 26 | void machine_shutdown(void) | ^~~~~~~~~~~~~~~~ arch/m68k/kernel/machine_kexec.c:30:6: warning: no previous prototype for 'machine_crash_shutdown' [-Wmissing-prototypes] 30 | void machine_crash_shutdown(struct pt_regs *regs) | ^~~~~~~~~~~~~~~~~~~~~~ -- In file included from include/linux/module.h:12, from arch/m68k/kernel/process.c:15: >> include/linux/list.h:662:8: warning: no previous prototype for 'list_count' [-Wmissing-prototypes] 662 | size_t list_count(struct list_head *head) | ^~~~~~~~~~ arch/m68k/kernel/process.c:114:16: warning: no previous prototype for 'm68k_clone' [-Wmissing-prototypes] 114 | asmlinkage int m68k_clone(struct pt_regs *regs) | ^~~~~~~~~~ arch/m68k/kernel/process.c:135:16: warning: no previous prototype for 'm68k_clone3' [-Wmissing-prototypes] 135 | asmlinkage int m68k_clone3(struct pt_regs *regs) | ^~~~~~~~~~~ arch/m68k/kernel/process.c:216:5: warning: no previous prototype for 'dump_fpu' [-Wmissing-prototypes] 216 | int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu) | ^~~~~~~~ .. vim +/list_count +662 include/linux/list.h 557 558 /** 559 * list_next_entry - get the next element in list 560 * @pos: the type * to cursor 561 * @member: the name of the list_head within the struct. 562 */ 563 #define list_next_entry(pos, member) \ 564 list_entry((pos)->member.next, typeof(*(pos)), member) 565 566 /** 567 * list_next_entry_circular - get the next element in list 568 * @pos: the type * to cursor. 569 * @head: the list head to take the element from. 570 * @member: the name of the list_head within the struct. 571 * 572 * Wraparound if pos is the last element (return the first element). 573 * Note, that list is expected to be not empty. 574 */ 575 #define list_next_entry_circular(pos, head, member) \ 576 (list_is_last(&(pos)->member, head) ? \ 577 list_first_entry(head, typeof(*(pos)), member) : list_next_entry(pos, member)) 578 579 /** 580 * list_prev_entry - get the prev element in list 581 * @pos: the type * to cursor 582 * @member: the name of the list_head within the struct. 583 */ 584 #define list_prev_entry(pos, member) \ 585 list_entry((pos)->member.prev, typeof(*(pos)), member) 586 587 /** 588 * list_prev_entry_circular - get the prev element in list 589 * @pos: the type * to cursor. 590 * @head: the list head to take the element from. 591 * @member: the name of the list_head within the struct. 592 * 593 * Wraparound if pos is the first element (return the last element). 594 * Note, that list is expected to be not empty. 595 */ 596 #define list_prev_entry_circular(pos, head, member) \ 597 (list_is_first(&(pos)->member, head) ? \ 598 list_last_entry(head, typeof(*(pos)), member) : list_prev_entry(pos, member)) 599 600 /** 601 * list_for_each - iterate over a list 602 * @pos: the &struct list_head to use as a loop cursor. 603 * @head: the head for your list. 604 */ 605 #define list_for_each(pos, head) \ 606 for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) 607 608 /** 609 * list_for_each_rcu - Iterate over a list in an RCU-safe fashion 610 * @pos: the &struct list_head to use as a loop cursor. 611 * @head: the head for your list. 612 */ 613 #define list_for_each_rcu(pos, head) \ 614 for (pos = rcu_dereference((head)->next); \ 615 !list_is_head(pos, (head)); \ 616 pos = rcu_dereference(pos->next)) 617 618 /** 619 * list_for_each_continue - continue iteration over a list 620 * @pos: the &struct list_head to use as a loop cursor. 621 * @head: the head for your list. 622 * 623 * Continue to iterate over a list, continuing after the current position. 624 */ 625 #define list_for_each_continue(pos, head) \ 626 for (pos = pos->next; !list_is_head(pos, (head)); pos = pos->next) 627 628 /** 629 * list_for_each_prev - iterate over a list backwards 630 * @pos: the &struct list_head to use as a loop cursor. 631 * @head: the head for your list. 632 */ 633 #define list_for_each_prev(pos, head) \ 634 for (pos = (head)->prev; !list_is_head(pos, (head)); pos = pos->prev) 635 636 /** 637 * list_for_each_safe - iterate over a list safe against removal of list entry 638 * @pos: the &struct list_head to use as a loop cursor. 639 * @n: another &struct list_head to use as temporary storage 640 * @head: the head for your list. 641 */ 642 #define list_for_each_safe(pos, n, head) \ 643 for (pos = (head)->next, n = pos->next; \ 644 !list_is_head(pos, (head)); \ 645 pos = n, n = pos->next) 646 647 /** 648 * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry 649 * @pos: the &struct list_head to use as a loop cursor. 650 * @n: another &struct list_head to use as temporary storage 651 * @head: the head for your list. 652 */ 653 #define list_for_each_prev_safe(pos, n, head) \ 654 for (pos = (head)->prev, n = pos->prev; \ 655 !list_is_head(pos, (head)); \ 656 pos = n, n = pos->prev) 657 658 /** 659 * list_count - count nodes in the list 660 * @head: the head for your list. 661 */ > 662 size_t list_count(struct list_head *head) 663 { 664 struct list_head *pos; 665 size_t count = 0; 666 667 list_for_each(pos, head) 668 count++; 669 670 return count; 671 } 672
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c index 6ae8b07cfaa1..b5d474be564d 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c @@ -2085,17 +2085,6 @@ static void print_request_ring(struct drm_printer *m, struct i915_request *rq) } } -static unsigned long list_count(struct list_head *list) -{ - struct list_head *pos; - unsigned long count = 0; - - list_for_each(pos, list) - count++; - - return count; -} - static unsigned long read_ul(void *p, size_t x) { return *(unsigned long *)(p + x); @@ -2270,7 +2259,7 @@ void intel_engine_dump(struct intel_engine_cs *engine, spin_lock_irqsave(&engine->sched_engine->lock, flags); engine_dump_active_requests(engine, m); - drm_printf(m, "\tOn hold?: %lu\n", + drm_printf(m, "\tOn hold?: %zu\n", list_count(&engine->sched_engine->hold)); spin_unlock_irqrestore(&engine->sched_engine->lock, flags); diff --git a/include/linux/list.h b/include/linux/list.h index 61762054b4be..65aab596ae33 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -655,6 +655,21 @@ static inline void list_splice_tail_init(struct list_head *list, !list_is_head(pos, (head)); \ pos = n, n = pos->prev) +/** + * list_count - count nodes in the list + * @head: the head for your list. + */ +size_t list_count(struct list_head *head) +{ + struct list_head *pos; + size_t count = 0; + + list_for_each(pos, head) + count++; + + return count; +} + /** * list_entry_is_head - test if the entry points to the head of the list * @pos: the type * to cursor