From patchwork Tue Mar 1 07:58:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Tong X-Patchwork-Id: 12764284 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74A13C433EF for ; Tue, 1 Mar 2022 07:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233187AbiCAH7l (ORCPT ); Tue, 1 Mar 2022 02:59:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230021AbiCAH7g (ORCPT ); Tue, 1 Mar 2022 02:59:36 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFCF650E01; Mon, 28 Feb 2022 23:58:56 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id g21so7148141pfj.11; Mon, 28 Feb 2022 23:58:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A25GcqUFVN2qz3QO76ICHSNj41DHlj4ABgVqzMafhNg=; b=hVlBBk7cs3/dXDPXoxjOjlK9Y2BjNWryWa8KLFqkxMZ5ftNCcm0uTY3qgZ7j31jVdE NhAaG15pa6YHcqJrKGZ4lLVFaxxfcvKBBdFIiwMikx65WVALF2ZyVQ+KTVRaghMfTH0I p5g2esJOzzR3Yr587LNne8gGAKIjHfiX75OEHWXutMQKgC2pkNRDzvcLsmu7YRDSwyNt J5eed6MBS7KSGP0xLrSgVRfq8sjHu8/Z0Zr+42wZRfwZZLWen1ndY0pLNyxau4KukI7u OUORMosGY7bR8f0Hq3ApDq+5m6lWzaZIUan654q+W/RtAwKEhkenqXGM81YkqYfiFq30 jOvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=A25GcqUFVN2qz3QO76ICHSNj41DHlj4ABgVqzMafhNg=; b=kIFHCwtgahgelilqzEMTrPYK7hHobYi6y3zZ1OGtcy7jqdLJZAE6/iNFczrN2nhT5D Vf8qDRqjhNWFx0AqqVEZPFhOFc7xXuLoatkSZLqhHF2Lhfc0sWykKfMZmcTiWaHEJawp g3HoJcY4gxLU+39zwIXkB7ixuQjlZ8S6gMHRtkyUV86LdVEowlGugu9KSOcPeHQE12fE sR6FtOPH+DcF4SaguQAi3Lqy3UO9+fJz8WsHOzmolKp33UHafKlgdDRFhu9D87ms1Sbk BUZj2Zps/9rGhnpd8itdDIGl91i9i2xAXKKeg5VTTxqTHSoI8Qw80djo5m3TUVhIvJH9 cOfg== X-Gm-Message-State: AOAM530ihy40Y5Js1+TNCfZ8lDk8+z1fpSriO1ce0Jdq2GjaKChsGlST ssyqTnBMo1caqjhkwqAk9dk= X-Google-Smtp-Source: ABdhPJwz/5TAUp9XKAqJDu66ccB4TZTOrvlYbd+foqA41ACOpsKAIWqQCfWfUYS1KUrpFS2b84vyqA== X-Received: by 2002:a05:6a00:2286:b0:4e1:285:5715 with SMTP id f6-20020a056a00228600b004e102855715mr26166424pfe.37.1646121536489; Mon, 28 Feb 2022 23:58:56 -0800 (PST) Received: from ubuntu.huawei.com ([119.3.119.18]) by smtp.googlemail.com with ESMTPSA id o12-20020a17090aac0c00b001b9e5286c90sm1662745pjq.0.2022.02.28.23.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 23:58:56 -0800 (PST) From: Xiaomeng Tong To: torvalds@linux-foundation.org Cc: arnd@arndb.de, jakobkoschel@gmail.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, keescook@chromium.org, jannh@google.com, linux-kbuild@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, Xiaomeng Tong Subject: [PATCH 1/6] Kbuild: compile kernel with gnu11 std Date: Tue, 1 Mar 2022 15:58:34 +0800 Message-Id: <20220301075839.4156-2-xiam0nd.tong@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220301075839.4156-1-xiam0nd.tong@gmail.com> References: <20220301075839.4156-1-xiam0nd.tong@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org This patch is suggested by linus[1], there may be some corner cases which should be considered before merge, and is just for prove PATCH 2. [1]: https://lore.kernel.org/all/CAHk-=wh97QY9fEQUK6zMVQwaQ_JWDvR=R+TxQ_0OYrMHQ+egvQ@mail.gmail.com/ Signed-off-by: Xiaomeng Tong Reported-by: kernel test robot --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 289ce2be8..84a96ae3c 100644 --- a/Makefile +++ b/Makefile @@ -515,7 +515,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ -Werror=implicit-function-declaration -Werror=implicit-int \ -Werror=return-type -Wno-format-security \ - -std=gnu89 + -std=gnu11 -Wno-shift-negative-value KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := From patchwork Tue Mar 1 07:58:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Tong X-Patchwork-Id: 12764285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F89AC433F5 for ; Tue, 1 Mar 2022 07:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233190AbiCAH7s (ORCPT ); Tue, 1 Mar 2022 02:59:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233193AbiCAH7r (ORCPT ); Tue, 1 Mar 2022 02:59:47 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A181C50E03; Mon, 28 Feb 2022 23:59:03 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id b8so13389637pjb.4; Mon, 28 Feb 2022 23:59:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YmXLEDuShcOW3JnBcgY++d4c0kg2D36rSz3AenVtmRY=; b=P+Lo9i6QowRAx0EEntsNvNUxCt1I6HaXTfmY+33mqDxWWil2KSfipziM4Nn/14h0Oq z3ypRqxwexLrfYlQJoFd5+rVz7UslgYwUmHKWvJwvuKairaWtKd3veo5qsliUZ77MFPs 4HnpB+JqFuavKk7cpK2Xv26KsS2ayZZif2Pr2d/FgeJA2JDTyHKjs7+K7Ws+K0zgWKRI ruFI6zDEScMjqU+vBM3+W3qJPu1gsLFAzxWdPEOww2yB+9dZENlLnBl8qdXU/rKNsiTR Eg+MOzpR1yqVnUoWa8XtPdBWxpwcFODjLHq/RzIc9anKNpZ0JutOuz4IzAjjjND7Pu74 wYFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YmXLEDuShcOW3JnBcgY++d4c0kg2D36rSz3AenVtmRY=; b=h0xc4E5hZjhr3VBZ7Hc/gAcRMCBZt+gWhh5Jf0kbUt4W/kMbzOpNcIIIbD3HcVyTh/ DMxn9A/+0y0RhjDaeYbqlb9yvG6ZwpSsWqI+SAwAagYUM4KTdKckhtfbPGOIl4mBQryh MhNPA9hmwE388LypyCAmq8aJFBB9v1PU7JtYvRqAxzlaxCdRA4GbI2ekrhRk+9mBRgMl fdlLV6SDmSQydxdmEWTR+cDKxHq7RjKqyKKevVZDN1nJFurG3Gw2aCfihu4wX1f4zP/A I85NQFQGaELtNbHGtglU6gSSmmE8PfFZo/wTKGbOWhlTKjfg3kDqYld+S5JyDHn3Jrdj HnKA== X-Gm-Message-State: AOAM530k5BclnEQB3LgCwojt9NF/kP8yuapWfF7jEJYbJwX15yFrbcnB Iup6qT1E0YKSDnovWx38Sb4= X-Google-Smtp-Source: ABdhPJzyKErM8pnzRaH8ojeB27k6eMiFHyMnxjPUJP6pxbk0TO4CP5X8i6d+VfvO4iKjFenzpV33QA== X-Received: by 2002:a17:902:7d83:b0:14e:f2f4:743 with SMTP id a3-20020a1709027d8300b0014ef2f40743mr24258960plm.107.1646121542543; Mon, 28 Feb 2022 23:59:02 -0800 (PST) Received: from ubuntu.huawei.com ([119.3.119.18]) by smtp.googlemail.com with ESMTPSA id o12-20020a17090aac0c00b001b9e5286c90sm1662745pjq.0.2022.02.28.23.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 23:59:02 -0800 (PST) From: Xiaomeng Tong To: torvalds@linux-foundation.org Cc: arnd@arndb.de, jakobkoschel@gmail.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, keescook@chromium.org, jannh@google.com, linux-kbuild@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, Xiaomeng Tong Subject: [PATCH 2/6] list: add new MACROs to make iterator invisiable outside the loop Date: Tue, 1 Mar 2022 15:58:35 +0800 Message-Id: <20220301075839.4156-3-xiam0nd.tong@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220301075839.4156-1-xiam0nd.tong@gmail.com> References: <20220301075839.4156-1-xiam0nd.tong@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org For each list_for_each_entry* macros(10 variants), implements a respective new *_inside one. Such as the new macro list_for_each_entry_inside for list_for_each_entry. The idea is to be as compatible with the original interface as possible and to minimize code changes. Here are 2 examples: list_for_each_entry_inside: - declare the iterator-variable pos inside the loop. Thus, the origin declare of the inputed *pos* outside the loop should be removed. In other words, the inputed *pos* now is just a string name. - add a new "type" argument as the type of the container struct this is embedded in, and should be inputed when calling the macro. list_for_each_entry_safe_continue_inside: - declare the iterator-variable pos and n inside the loop. Thus, the origin declares of the inputed *pos* and *n* outside the loop should be removed. In other words, the inputed *pos* and *n* now are just string name. - add a new "start" argument as the given iterator to start with and can be used to get the container struct *type*. This should be inputed when calling the macro. Signed-off-by: Xiaomeng Tong Reported-by: kernel test robot --- include/linux/list.h | 156 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index dd6c2041d..1595ce865 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -639,6 +639,19 @@ static inline void list_splice_tail_init(struct list_head *list, !list_entry_is_head(pos, head, member); \ pos = list_next_entry(pos, member)) +/** + * list_for_each_entry_inside + * - iterate over list of given type and keep iterator inside the loop + * @pos: the type * to use as a loop cursor. + * @type: the type of the container struct this is embedded in. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + */ +#define list_for_each_entry_inside(pos, type, head, member) \ + for (type * pos = list_first_entry(head, type, member); \ + !list_entry_is_head(pos, head, member); \ + pos = list_next_entry(pos, member)) + /** * list_for_each_entry_reverse - iterate backwards over list of given type. * @pos: the type * to use as a loop cursor. @@ -650,6 +663,19 @@ static inline void list_splice_tail_init(struct list_head *list, !list_entry_is_head(pos, head, member); \ pos = list_prev_entry(pos, member)) +/** + * list_for_each_entry_reverse_inside + * - iterate backwards over list of given type and keep iterator inside the loop. + * @pos: the type * to use as a loop cursor. + * @type: the type of the container struct this is embedded in. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + */ +#define list_for_each_entry_reverse_inside(pos, type, head, member) \ + for (type * pos = list_last_entry(head, type, member); \ + !list_entry_is_head(pos, head, member); \ + pos = list_prev_entry(pos, member)) + /** * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue() * @pos: the type * to use as a start point @@ -675,6 +701,22 @@ static inline void list_splice_tail_init(struct list_head *list, !list_entry_is_head(pos, head, member); \ pos = list_next_entry(pos, member)) +/** + * list_for_each_entry_continue_inside + * - continue iteration over list of given type and keep iterator inside the loop + * @pos: the type * to use as a loop cursor. + * @start: the given iterator to start with. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + * + * Continue to iterate over list of given type, continuing after + * the current position. + */ +#define list_for_each_entry_continue_inside(pos, start, head, member) \ + for (typeof(*start) *pos = list_next_entry(start, member); \ + !list_entry_is_head(pos, head, member); \ + pos = list_next_entry(pos, member)) + /** * list_for_each_entry_continue_reverse - iterate backwards from the given point * @pos: the type * to use as a loop cursor. @@ -689,6 +731,22 @@ static inline void list_splice_tail_init(struct list_head *list, !list_entry_is_head(pos, head, member); \ pos = list_prev_entry(pos, member)) +/** + * list_for_each_entry_continue_reverse_inside + * - iterate backwards from the given point and keep iterator inside the loop + * @pos: the type * to use as a loop cursor. + * @start: the given iterator to start with. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + * + * Start to iterate over list of given type backwards, continuing after + * the current position. + */ +#define list_for_each_entry_continue_reverse_inside(pos, start, head, member) \ + for (typeof(*start) *pos = list_prev_entry(start, member); \ + !list_entry_is_head(pos, head, member); \ + pos = list_prev_entry(pos, member)) + /** * list_for_each_entry_from - iterate over list of given type from the current point * @pos: the type * to use as a loop cursor. @@ -701,6 +759,20 @@ static inline void list_splice_tail_init(struct list_head *list, for (; !list_entry_is_head(pos, head, member); \ pos = list_next_entry(pos, member)) +/** + * list_for_each_entry_from_inside + * - iterate over list of given type from the current point and keep iterator inside the loop + * @pos: the type * to use as a loop cursor. + * @start: the given iterator to start with. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + * + * Iterate over list of given type, continuing from current position. + */ +#define list_for_each_entry_from_inside(pos, start, head, member) \ + for (typeof(*start) *pos = start; !list_entry_is_head(pos, head, member); \ + pos = list_next_entry(pos, member)) + /** * list_for_each_entry_from_reverse - iterate backwards over list of given type * from the current point @@ -714,6 +786,21 @@ static inline void list_splice_tail_init(struct list_head *list, for (; !list_entry_is_head(pos, head, member); \ pos = list_prev_entry(pos, member)) +/** + * list_for_each_entry_from_reverse_inside + * - iterate backwards over list of given type from the current point + * and keep iterator inside the loop + * @pos: the type * to use as a loop cursor. + * @start: the given iterator to start with. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + * + * Iterate backwards over list of given type, continuing from current position. + */ +#define list_for_each_entry_from_reverse_inside(pos, start, head, member) \ + for (typeof(*start) *pos = start; !list_entry_is_head(pos, head, member); \ + pos = list_prev_entry(pos, member)) + /** * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry * @pos: the type * to use as a loop cursor. @@ -727,6 +814,22 @@ static inline void list_splice_tail_init(struct list_head *list, !list_entry_is_head(pos, head, member); \ pos = n, n = list_next_entry(n, member)) +/** + * list_for_each_entry_safe_inside + * - iterate over list of given type safe against removal of list entry + * and keep iterator inside the loop + * @pos: the type * to use as a loop cursor. + * @n: another type * to use as temporary storage + * @type: the type of the container struct this is embedded in. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + */ +#define list_for_each_entry_safe_inside(pos, n, type, head, member) \ + for (type * pos = list_first_entry(head, type, member), \ + *n = list_next_entry(pos, member); \ + !list_entry_is_head(pos, head, member); \ + pos = n, n = list_next_entry(n, member)) + /** * list_for_each_entry_safe_continue - continue list iteration safe against removal * @pos: the type * to use as a loop cursor. @@ -743,6 +846,24 @@ static inline void list_splice_tail_init(struct list_head *list, !list_entry_is_head(pos, head, member); \ pos = n, n = list_next_entry(n, member)) +/** + * list_for_each_entry_safe_continue_inside + * - continue list iteration safe against removal and keep iterator inside the loop + * @pos: the type * to use as a loop cursor. + * @n: another type * to use as temporary storage + * @start: the given iterator to start with. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + * + * Iterate over list of given type, continuing after current point, + * safe against removal of list entry. + */ +#define list_for_each_entry_safe_continue_inside(pos, n, start, head, member) \ + for (typeof(*start) *pos = list_next_entry(start, member), \ + *n = list_next_entry(pos, member); \ + !list_entry_is_head(pos, head, member); \ + pos = n, n = list_next_entry(n, member)) + /** * list_for_each_entry_safe_from - iterate over list from current point safe against removal * @pos: the type * to use as a loop cursor. @@ -758,6 +879,23 @@ static inline void list_splice_tail_init(struct list_head *list, !list_entry_is_head(pos, head, member); \ pos = n, n = list_next_entry(n, member)) +/** + * list_for_each_entry_safe_from_inside + * - iterate over list from current point safe against removal and keep iterator inside the loop + * @pos: the type * to use as a loop cursor. + * @n: another type * to use as temporary storage + * @start: the given iterator to start with. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + * + * Iterate over list of given type from current point, safe against + * removal of list entry. + */ +#define list_for_each_entry_safe_from_inside(pos, n, start, head, member) \ + for (typeof(*start) *pos = start, *n = list_next_entry(pos, member); \ + !list_entry_is_head(pos, head, member); \ + pos = n, n = list_next_entry(n, member)) + /** * list_for_each_entry_safe_reverse - iterate backwards over list safe against removal * @pos: the type * to use as a loop cursor. @@ -774,6 +912,24 @@ static inline void list_splice_tail_init(struct list_head *list, !list_entry_is_head(pos, head, member); \ pos = n, n = list_prev_entry(n, member)) +/** + * list_for_each_entry_safe_reverse_insde + * - iterate backwards over list safe against removal and keep iterator inside the loop + * @pos: the type * to use as a loop cursor. + * @n: another type * to use as temporary storage + * @type: the type of the struct this is enmbeded in. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + * + * Iterate backwards over list of given type, safe against removal + * of list entry. + */ +#define list_for_each_entry_safe_reverse_inside(pos, n, type, head, member) \ + for (type * pos = list_last_entry(head, type, member), \ + *n = list_prev_entry(pos, member); \ + !list_entry_is_head(pos, head, member); \ + pos = n, n = list_prev_entry(n, member)) + /** * list_safe_reset_next - reset a stale list_for_each_entry_safe loop * @pos: the loop cursor used in the list_for_each_entry_safe loop From patchwork Tue Mar 1 07:58:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Tong X-Patchwork-Id: 12764286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56518C43217 for ; Tue, 1 Mar 2022 07:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233197AbiCAH7t (ORCPT ); Tue, 1 Mar 2022 02:59:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233172AbiCAH7s (ORCPT ); Tue, 1 Mar 2022 02:59:48 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D1CC50E03; Mon, 28 Feb 2022 23:59:08 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id o26so13113641pgb.8; Mon, 28 Feb 2022 23:59:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QzqMQ7hY2MYfklNGeKF7LFcaPkZedhmqr5FhyMheFwo=; b=gVxF1LdSpG+k8ok8OMNRdDVtLVE/NqVwo2cuhWNRniKttJozJwf5d6VZzH1i92tcfk LjvV2n6up3BQHyac+coxsykXnz5tWVcVghrIO/tq32iI8qFez1io7PrDuupWuIK5szwX qEjlBQh+0f4d0L0OTTiYJtjiL5fRe2VA3Yct7uyzXCmqDfkhSWwiAarqiCN4a3N/VHCX zWewXOlqmVeI74ZEOxGPYEkH6z5Gys0pTYAPlWV7VdU0/ZCr3lP8qsP0igB+sK6iL7i0 GV3sXSENLbKqbl8ye1/LTCIdneSxT7Wqtw/pCXiNbKTPso4aWiY4bMLS4DiiToakIcIN HbIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QzqMQ7hY2MYfklNGeKF7LFcaPkZedhmqr5FhyMheFwo=; b=pMBNSIBOBG5eMnCSleLMo4D43yeJdYpODTR6zZic5a8j/QguxrioAqin0vl1rMNN4w sZ+WwDmW+89o/eUU2v1gE0iS4VF87V/9LsJdes+3ccneroFSCkZo7Y3/fJsYeLtFgtg7 x0isAIBdIrkaf1EfVHgjezCsfBjAY8KP0PTzNIYzU6+SxffRWSwfu4CxjQkdPAF1bFrz Pi/brAczQ5dBVEsLK8NQKybJi9HAYmUXA7ri9aaV2Adc6QG7XHu2GjivOt3DWPJgtO6H rvWPXToQVMi5w9ukMGZ2ql1Cbm2WLxWS4HOexrn0QZ0V0YYO04/M40V3y/eK/nxybRwd QADw== X-Gm-Message-State: AOAM531fq0aFPfVq6kqyMsz7V/JQMu3uYIj+WXbg80hmV1erFi8KKS9I LGTYKncn3hQjceZ+rZfZo6I= X-Google-Smtp-Source: ABdhPJyuoS68KxM7xG7Clm6TRMSCvt/W4vvf7HErAeAb32bAA7KFsQ5E8Cn37Dg0u8Z/+37AV7q49Q== X-Received: by 2002:a05:6a00:1312:b0:4e1:58c4:ddfd with SMTP id j18-20020a056a00131200b004e158c4ddfdmr26133089pfu.65.1646121548180; Mon, 28 Feb 2022 23:59:08 -0800 (PST) Received: from ubuntu.huawei.com ([119.3.119.18]) by smtp.googlemail.com with ESMTPSA id o12-20020a17090aac0c00b001b9e5286c90sm1662745pjq.0.2022.02.28.23.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 23:59:07 -0800 (PST) From: Xiaomeng Tong To: torvalds@linux-foundation.org Cc: arnd@arndb.de, jakobkoschel@gmail.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, keescook@chromium.org, jannh@google.com, linux-kbuild@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, Xiaomeng Tong Subject: [PATCH 3/6] kernel: remove iterator use outside the loop Date: Tue, 1 Mar 2022 15:58:36 +0800 Message-Id: <20220301075839.4156-4-xiam0nd.tong@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220301075839.4156-1-xiam0nd.tong@gmail.com> References: <20220301075839.4156-1-xiam0nd.tong@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Demonstrations for: - list_for_each_entry_inside - list_for_each_entry_continue_inside - list_for_each_entry_safe_continue_inside Signed-off-by: Xiaomeng Tong --- kernel/power/snapshot.c | 28 ++++++++++++++++------------ kernel/signal.c | 6 +++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 330d49937..75958b5fa 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c @@ -625,16 +625,18 @@ static int create_mem_extents(struct list_head *list, gfp_t gfp_mask) for_each_populated_zone(zone) { unsigned long zone_start, zone_end; - struct mem_extent *ext, *cur, *aux; + struct mem_extent *me = NULL; zone_start = zone->zone_start_pfn; zone_end = zone_end_pfn(zone); - list_for_each_entry(ext, list, hook) - if (zone_start <= ext->end) + list_for_each_entry_inside(ext, struct mem_extent, list, hook) + if (zone_start <= ext->end) { + me = ext; break; + } - if (&ext->hook == list || zone_end < ext->start) { + if (!me || zone_end < me->start) { /* New extent is necessary */ struct mem_extent *new_ext; @@ -645,23 +647,25 @@ static int create_mem_extents(struct list_head *list, gfp_t gfp_mask) } new_ext->start = zone_start; new_ext->end = zone_end; - list_add_tail(&new_ext->hook, &ext->hook); + if (!me) + list_add_tail(&new_ext->hook, list); + else + list_add_tail(&new_ext->hook, &me->hook); continue; } /* Merge this zone's range of PFNs with the existing one */ - if (zone_start < ext->start) - ext->start = zone_start; - if (zone_end > ext->end) - ext->end = zone_end; + if (zone_start < me->start) + me->start = zone_start; + if (zone_end > me->end) + me->end = zone_end; /* More merging may be possible */ - cur = ext; - list_for_each_entry_safe_continue(cur, aux, list, hook) { + list_for_each_entry_safe_continue_inside(cur, aux, me, list, hook) { if (zone_end < cur->start) break; if (zone_end < cur->end) - ext->end = cur->end; + me->end = cur->end; list_del(&cur->hook); kfree(cur); } diff --git a/kernel/signal.c b/kernel/signal.c index 9b04631ac..da2c20de1 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -711,7 +711,7 @@ static int dequeue_synchronous_signal(kernel_siginfo_t *info) { struct task_struct *tsk = current; struct sigpending *pending = &tsk->pending; - struct sigqueue *q, *sync = NULL; + struct sigqueue *sync = NULL; /* * Might a synchronous signal be in the queue? @@ -722,7 +722,7 @@ static int dequeue_synchronous_signal(kernel_siginfo_t *info) /* * Return the first synchronous signal in the queue. */ - list_for_each_entry(q, &pending->list, list) { + list_for_each_entry_inside(q, struct sigqueue, &pending->list, list) { /* Synchronous signals have a positive si_code */ if ((q->info.si_code > SI_USER) && (sigmask(q->info.si_signo) & SYNCHRONOUS_MASK)) { @@ -735,7 +735,7 @@ static int dequeue_synchronous_signal(kernel_siginfo_t *info) /* * Check if there is another siginfo for the same signal. */ - list_for_each_entry_continue(q, &pending->list, list) { + list_for_each_entry_continue_inside(q, sync, &pending->list, list) { if (q->info.si_signo == sync->info.si_signo) goto still_pending; } From patchwork Tue Mar 1 07:58:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Tong X-Patchwork-Id: 12764287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0767C433F5 for ; Tue, 1 Mar 2022 07:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233178AbiCAH77 (ORCPT ); Tue, 1 Mar 2022 02:59:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233172AbiCAH74 (ORCPT ); Tue, 1 Mar 2022 02:59:56 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7420D80222; Mon, 28 Feb 2022 23:59:14 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id ev16-20020a17090aead000b001bc3835fea8so1547244pjb.0; Mon, 28 Feb 2022 23:59:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DH7q20NUg2fMsVec64lFAIumDGct4fZ105Sw3WAxbUA=; b=HLRBF069/um4dwnSHVDbI8dMFG7O4YOwO13iD6T3NtC46gVCf+cqdA32nJr444gw/e ZGXMD/+Sq19GBj7ri2stQfg2YRHBVyL1h3wjdYyUNAQFRvV/NO/yhTObYAjYR6yB4O1P R2gnrnnWh7bFxCGgXzrazITF3jtmnFfFzcl8cTwldg9M0evnPLez8C4LIY0MzmQU5Gr6 WWooK8bKBefjGTEctbNTWyvit1VOWagfNoh+RIOqOTt7wVNiBBvqpSh0+CtHAwc2RXTL eiYUzqx5xKpj02Dnqcwx6p2YICPj+SXQrmhNW655CZVzyEClYIKvi+T8zCIx067+f19l ALgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DH7q20NUg2fMsVec64lFAIumDGct4fZ105Sw3WAxbUA=; b=5Pkw/d/qZhQba4OJro+F5IT5ZOnl1A5gWq3zMzDnr+Yp0mKQ2gvalj912bvKPqQJ4C ycL9Pgb+b7h6XxHVP79cAqkp7g5Vqh4o9bUJcxPwngNkh32QIdxfLrMN9W789h4x18zT ua7x5kmxl2/QLUNIwcHUlqvnbQ4zEb9exfDQ+caIundXC7lbXh6Sorcz0B+BJYHYDu+u QZtOo6o4vJ+e6T9cuUvq2VcVRKarToIvep6ap3xTvOxSLuh9yEa/4HBVAlM67dB17cyl Ocxcmi8CsIuR3X2xc0sXbdKI9clQFk1udTX+y9hWnQUTCKyqxdyBoRX3I5/Bfeii/oUI pvMg== X-Gm-Message-State: AOAM533at2Taa5KzFzW4Q454H2w26qgaKNs8W/yBSocmyMxOQx9XqI94 nNZZ4vzEm2Ogg3tQSGjB1ak= X-Google-Smtp-Source: ABdhPJzfIGUgp26nNkeuQ+F6tXH5OU7cPOWBmYg0OuNdWuCuc04wHa/W/eDEP40nsuuNMSdEw+IExA== X-Received: by 2002:a17:90a:788f:b0:1bd:59c5:748e with SMTP id x15-20020a17090a788f00b001bd59c5748emr7588034pjk.158.1646121554019; Mon, 28 Feb 2022 23:59:14 -0800 (PST) Received: from ubuntu.huawei.com ([119.3.119.18]) by smtp.googlemail.com with ESMTPSA id o12-20020a17090aac0c00b001b9e5286c90sm1662745pjq.0.2022.02.28.23.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 23:59:13 -0800 (PST) From: Xiaomeng Tong To: torvalds@linux-foundation.org Cc: arnd@arndb.de, jakobkoschel@gmail.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, keescook@chromium.org, jannh@google.com, linux-kbuild@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, Xiaomeng Tong Subject: [PATCH 4/6] mm: remove iterator use outside the loop Date: Tue, 1 Mar 2022 15:58:37 +0800 Message-Id: <20220301075839.4156-5-xiam0nd.tong@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220301075839.4156-1-xiam0nd.tong@gmail.com> References: <20220301075839.4156-1-xiam0nd.tong@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Demonstrations for: - list_for_each_entry_inside - list_for_each_entry_reverse_inside - list_for_each_entry_safe_inside - list_for_each_entry_from_inside - list_for_each_entry_continue_reverse_inside Signed-off-by: Xiaomeng Tong --- mm/list_lru.c | 10 ++++++---- mm/slab_common.c | 7 ++----- mm/vmalloc.c | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/mm/list_lru.c b/mm/list_lru.c index 0cd5e89ca..d8aab53a7 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -493,20 +493,22 @@ static void memcg_cancel_update_list_lru(struct list_lru *lru, int memcg_update_all_list_lrus(int new_size) { int ret = 0; - struct list_lru *lru; + struct list_lru *ll = NULL; int old_size = memcg_nr_cache_ids; mutex_lock(&list_lrus_mutex); - list_for_each_entry(lru, &memcg_list_lrus, list) { + list_for_each_entry_inside(lru, struct list_lru, &memcg_list_lrus, list) { ret = memcg_update_list_lru(lru, old_size, new_size); - if (ret) + if (ret) { + ll = lru; goto fail; + } } out: mutex_unlock(&list_lrus_mutex); return ret; fail: - list_for_each_entry_continue_reverse(lru, &memcg_list_lrus, list) + list_for_each_entry_continue_reverse_inside(lru, ll, &memcg_list_lrus, list) memcg_cancel_update_list_lru(lru, old_size, new_size); goto out; } diff --git a/mm/slab_common.c b/mm/slab_common.c index 23f2ab071..68a25d385 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -186,8 +186,6 @@ int slab_unmergeable(struct kmem_cache *s) struct kmem_cache *find_mergeable(unsigned int size, unsigned int align, slab_flags_t flags, const char *name, void (*ctor)(void *)) { - struct kmem_cache *s; - if (slab_nomerge) return NULL; @@ -202,7 +200,7 @@ struct kmem_cache *find_mergeable(unsigned int size, unsigned int align, if (flags & SLAB_NEVER_MERGE) return NULL; - list_for_each_entry_reverse(s, &slab_caches, list) { + list_for_each_entry_reverse_inside(s, struct kmem_cache, &slab_caches, list) { if (slab_unmergeable(s)) continue; @@ -419,7 +417,6 @@ EXPORT_SYMBOL(kmem_cache_create); static void slab_caches_to_rcu_destroy_workfn(struct work_struct *work) { LIST_HEAD(to_destroy); - struct kmem_cache *s, *s2; /* * On destruction, SLAB_TYPESAFE_BY_RCU kmem_caches are put on the @@ -439,7 +436,7 @@ static void slab_caches_to_rcu_destroy_workfn(struct work_struct *work) rcu_barrier(); - list_for_each_entry_safe(s, s2, &to_destroy, list) { + list_for_each_entry_safe_inside(s, s2, struct kmem_cache, &to_destroy, list) { debugfs_slab_release(s); kfence_shutdown_cache(s); #ifdef SLAB_SUPPORTS_SYSFS diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 4165304d3..65a9f1db7 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3417,14 +3417,14 @@ long vread(char *buf, char *addr, unsigned long count) if ((unsigned long)addr + count <= va->va_start) goto finished; - list_for_each_entry_from(va, &vmap_area_list, list) { + list_for_each_entry_from_inside(iter, va, &vmap_area_list, list) { if (!count) break; - if (!va->vm) + if (!iter->vm) continue; - vm = va->vm; + vm = iter->vm; vaddr = (char *) vm->addr; if (addr >= vaddr + get_vm_area_size(vm)) continue; From patchwork Tue Mar 1 07:58:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Tong X-Patchwork-Id: 12764288 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF244C433F5 for ; Tue, 1 Mar 2022 07:59:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233215AbiCAIAN (ORCPT ); Tue, 1 Mar 2022 03:00:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233231AbiCAIAD (ORCPT ); Tue, 1 Mar 2022 03:00:03 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 601CB8090B; Mon, 28 Feb 2022 23:59:20 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id o23so13742755pgk.13; Mon, 28 Feb 2022 23:59:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3aKejJw1nR/er0PaT33ysU9JAPbiP/BO+fmavRczddA=; b=MkwrLGU+BDmEg5akmiJV5iuAGXoVQex9eAJamjRI5yPEwQz5ZBphS8rWxnJoh6r2qk GITpdBUCOCJKhpDPKvimmGQSnQYAGyWqE3P/+tlqY8/Lu4X9F1UCmP0Z1BSnNx23hj2H UtRYDHpyz0wyS3HBEihDOvYCmXO68ii5OY2AqwLcziJx5hhINrQq37iUPti6770WqH72 1+XtxGGGSMNbhBmEy4L8XvJ2nezmqom4+TByy//BriSjcIkpn9hXnEZncRbOhKFatyZi G1bY7lVc2k/YjXTfPPTknwvPMtj6AurwobswVDg4xT3ibtE/DX12Ms7BPAu681KRpKyf EYkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3aKejJw1nR/er0PaT33ysU9JAPbiP/BO+fmavRczddA=; b=aPg/ZZYJR+aafrSCj9GTFsiWmVBC9lZeRteTOUge7H5yjZg/qY/U83R2hP6vJVEnhG VaGU/Ebpy1i4VpfHuq+l+UJHbtIYKn3nkHVKADwG6uBj/xn8dal4yRmTS6ggJLJXAVsC wWlD82ip0nDyw+Iu4a/Q55KghEDLTAnMbXu1yqFNpwqu+tUKD3uOsCdkYV3ZP3iX/BJR L1UiV24ITHpSfhp64JBX7OSvUvXmvs9azPwb1MZkKqyXNjl/8c2dCsdYfV1Qy2LPAZCJ N5JiUWyQilm7zKdwEqqKXtDMKS9ItMaFmohq63CCCfo6A2MiT+DCatPdZGtsMNPE6+Qe 0+pg== X-Gm-Message-State: AOAM533FoX659XT/MV9im14G8t47+b3HRA/HHdghZwunrd72QnzubHBw nmfIyqHP1doVToyeEmofq9U= X-Google-Smtp-Source: ABdhPJzsmChq0SMT6w+a5llB+evOvw/vtlrBOBuie32yTHIMn9w2PHQgwGyq50KU4/df9sG257/q1g== X-Received: by 2002:a05:6a00:124f:b0:4c0:6242:c14e with SMTP id u15-20020a056a00124f00b004c06242c14emr25860679pfi.83.1646121559737; Mon, 28 Feb 2022 23:59:19 -0800 (PST) Received: from ubuntu.huawei.com ([119.3.119.18]) by smtp.googlemail.com with ESMTPSA id o12-20020a17090aac0c00b001b9e5286c90sm1662745pjq.0.2022.02.28.23.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 23:59:19 -0800 (PST) From: Xiaomeng Tong To: torvalds@linux-foundation.org Cc: arnd@arndb.de, jakobkoschel@gmail.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, keescook@chromium.org, jannh@google.com, linux-kbuild@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, Xiaomeng Tong Subject: [PATCH 5/6] net/core: remove iterator use outside the loop Date: Tue, 1 Mar 2022 15:58:38 +0800 Message-Id: <20220301075839.4156-6-xiam0nd.tong@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220301075839.4156-1-xiam0nd.tong@gmail.com> References: <20220301075839.4156-1-xiam0nd.tong@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Demonstrations for: - list_for_each_entry_safe_reverse_inside Signed-off-by: Xiaomeng Tong --- net/core/gro.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/core/gro.c b/net/core/gro.c index a11b286d1..4d4f1f2fb 100644 --- a/net/core/gro.c +++ b/net/core/gro.c @@ -286,9 +286,8 @@ static void __napi_gro_flush_chain(struct napi_struct *napi, u32 index, bool flush_old) { struct list_head *head = &napi->gro_hash[index].list; - struct sk_buff *skb, *p; - list_for_each_entry_safe_reverse(skb, p, head, list) { + list_for_each_entry_safe_reverse_inside(skb, p, struct sk_buff, head, list) { if (flush_old && NAPI_GRO_CB(skb)->age == jiffies) return; skb_list_del_init(skb); From patchwork Tue Mar 1 07:58:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Tong X-Patchwork-Id: 12764289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0E5AC433F5 for ; Tue, 1 Mar 2022 07:59:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233241AbiCAIAQ (ORCPT ); Tue, 1 Mar 2022 03:00:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233243AbiCAIAN (ORCPT ); Tue, 1 Mar 2022 03:00:13 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E021C80202; Mon, 28 Feb 2022 23:59:25 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id o26so13114111pgb.8; Mon, 28 Feb 2022 23:59:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ekN4siAZvBFYd9yFklz7czO7Ig0JL/XxTSkd0vY2Yt8=; b=Kz+4lJxpn6ZgNlG3qZPKUsrxvOx+u6q7ExG1ZalqIm2eoUgzkmKQ18EPS8Y2gJ91ws ok2nLgOjheo5Q+JkSgWrbzHDQpQa5YOuFW3unn1k1/7oZ0HgwPOrZIe2pesso6MHMbRP bZzU3Cz9/18EGeHCFtChKtNwLPgdwcTb5joSEyWFCDalPn4pWeVOSJaVpa2UJWelNXo7 nW275yP5KtdIIFFzENZdI2cq35OKDfDJ47rPXJa5QgRa8MoylJN0zGyv7syuj6ACJMJU wP71gwseBBGoxOdHN/stX4Rz3Pzt08bTEZ5h4DDmVo+SpG06gBNUEOGFabRPha8U2EyC LGvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ekN4siAZvBFYd9yFklz7czO7Ig0JL/XxTSkd0vY2Yt8=; b=qjakPSBE9JzxrT/Wt7xgbpSFdVCq3DWqKHh+soM2CqqjwsN528xtqS1zVt/pzEY5ZF zOUXDtLVBT/E662Ttourc/d+4QoJR51nZhJVtzFk4ov1szJbI323p+5muKpVrOPiZcq9 g1rA1vP17QapX2v32VMYx1wYGS/kEdMERMJaQ3WHoaCOxA+tWkTzwtEcnmKug/rrbYVw kp282tBJ0YGxDKZYO2xX4WgP95EP6QpSTpTqYdPPSrNqbi3P2z711RS+olGyvbkieCkd iU6YZOxzkNf6+kKmVhatTnugWQTWhfyfbwrr4aWuyQm6VUf1saibeXJTbwawLj4bjkSo c+Zw== X-Gm-Message-State: AOAM532T6+jKK574QLvSFtJrCKFFe0pKNp/5Egha+31q2/6Nz5PaFJ8L akv+8wMsq03fo9MiwF57kJtJMdgdZ2pylg== X-Google-Smtp-Source: ABdhPJwXvPb7Q40+8gxqteNpuZwp+PE+h/n6nJyCxWSbGjj0S4pZaxg41DZenCjeRXk3a7weBaal7A== X-Received: by 2002:a65:680a:0:b0:34d:efd6:7a5f with SMTP id l10-20020a65680a000000b0034defd67a5fmr20435429pgt.213.1646121565470; Mon, 28 Feb 2022 23:59:25 -0800 (PST) Received: from ubuntu.huawei.com ([119.3.119.18]) by smtp.googlemail.com with ESMTPSA id o12-20020a17090aac0c00b001b9e5286c90sm1662745pjq.0.2022.02.28.23.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 23:59:25 -0800 (PST) From: Xiaomeng Tong To: torvalds@linux-foundation.org Cc: arnd@arndb.de, jakobkoschel@gmail.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, keescook@chromium.org, jannh@google.com, linux-kbuild@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, Xiaomeng Tong Subject: [PATCH 6/6] drivers/dma: remove iterator use outside the loop Date: Tue, 1 Mar 2022 15:58:39 +0800 Message-Id: <20220301075839.4156-7-xiam0nd.tong@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220301075839.4156-1-xiam0nd.tong@gmail.com> References: <20220301075839.4156-1-xiam0nd.tong@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Demonstrations for: - list_for_each_entry_from_inside - list_for_each_entry_safe_from_inside Signed-off-by: Xiaomeng Tong --- drivers/dma/iop-adma.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c index 310b899d5..2f326fb37 100644 --- a/drivers/dma/iop-adma.c +++ b/drivers/dma/iop-adma.c @@ -159,7 +159,6 @@ static void __iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan) /* all the members of a group are complete */ if (slots_per_op != 0 && slot_cnt == 0) { - struct iop_adma_desc_slot *grp_iter, *_grp_iter; int end_of_chain = 0; pr_debug("\tgroup end\n"); @@ -167,9 +166,8 @@ static void __iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan) if (grp_start->xor_check_result) { u32 zero_sum_result = 0; slot_cnt = grp_start->slot_cnt; - grp_iter = grp_start; - list_for_each_entry_from(grp_iter, + list_for_each_entry_from_inside(grp_iter, grp_start, &iop_chan->chain, chain_node) { zero_sum_result |= iop_desc_get_zero_result(grp_iter); @@ -186,9 +184,8 @@ static void __iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan) /* clean up the group */ slot_cnt = grp_start->slot_cnt; - grp_iter = grp_start; - list_for_each_entry_safe_from(grp_iter, _grp_iter, - &iop_chan->chain, chain_node) { + list_for_each_entry_safe_from_inside(grp_iter, _grp_iter, + grp_start, &iop_chan->chain, chain_node) { cookie = iop_adma_run_tx_complete_actions( grp_iter, iop_chan, cookie);