Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3872463ima; Mon, 4 Feb 2019 06:37:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IYwWNb3ulvfJpXjIFmgMlrCpgdQ1n6E+tNURSJEfQeCoaGDu4f6wVlkXXRA408nDcE8F95z X-Received: by 2002:a63:2303:: with SMTP id j3mr12286258pgj.391.1549291041895; Mon, 04 Feb 2019 06:37:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549291041; cv=none; d=google.com; s=arc-20160816; b=HQQlEXumyvYvdiVjdeGQTeH/uPKLtJ7lJ8zmALOMPjcMhKVJxcpd7uSctAqFD9xTng 8R2+n5xSnSrJqfUOQFuFgAFlpYV1nRwBVuPMCsyqZnI4mFcRasUE4FCndfL+8vwm0tRl XJ4X/BXdH21wiZTDz9uKXNJ8NGxXfLQOyuGot1VC4w0UMXJ1uOZ5ZjzA7560dqrS6fwW Do57InSNiRKEtCuuDGqvyjF8t9UXyjTuvTx2PqdShUibBN3ozHfJBskZxutJlyJ5z6hM xWj2/maLVhUI61PhHl6zv/on0E+XlRK/eyGIVC869ff+FnxiqYWusrPWan8U6ChBzt+1 9nUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=0W7DAcp+cW+4RIDuiA5puxF1VIhdy2hu+3R0FyV78Bw=; b=ZWTeg2uS0G5U8fwEjYX76kMKDQWrEypJwybx8cJUSxqdKpSemayg1CkA+YYL9aQ8zC jTwVU/C+d+INuNX3nLEghremCd67bsUEjkG5/hwSK7SgAP4lV8VrgmJTl+rvfXSY6OPf JY8X/cPAUjmBlh4AGbIhdDdXNJeSQeogJSR8cFr3AwiuRCpDnt7dy7ENhm8w78E0kYF9 cXchDD/36pAOpO8N2Oyxsw6nm23th0uTIlyHZNV7Og3kyWT8wTyFQe6u/2aPsQHMADs3 mm4M5oVZIfNNFV/7yqQSAi1NEaqMQ4tUjVmDtouLBS4Q0u7yGZ8T4dw7vz/U0yecrSpM b8/A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2si176997pgr.67.2019.02.04.06.37.05; Mon, 04 Feb 2019 06:37:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731446AbfBDN5G (ORCPT + 99 others); Mon, 4 Feb 2019 08:57:06 -0500 Received: from mx2.suse.de ([195.135.220.15]:35720 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729969AbfBDN5F (ORCPT ); Mon, 4 Feb 2019 08:57:05 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B5DD9ADD4; Mon, 4 Feb 2019 13:57:03 +0000 (UTC) From: Petr Mladek To: Jiri Kosina , Josh Poimboeuf , Miroslav Benes Cc: Jason Baron , Joe Lawrence , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH v2 1/4] livepatch: Introduce klp_for_each_patch macro Date: Mon, 4 Feb 2019 14:56:50 +0100 Message-Id: <20190204135653.31406-2-pmladek@suse.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20190204135653.31406-1-pmladek@suse.com> References: <20190204135653.31406-1-pmladek@suse.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are already macros to iterate over struct klp_func and klp_object. Add also klp_for_each_patch(). But make it internal because also klp_patches list is internal. Suggested-by: Josh Poimboeuf Signed-off-by: Petr Mladek Acked-by: Miroslav Benes Acked-by: Joe Lawrence --- kernel/livepatch/core.c | 8 ++++---- kernel/livepatch/core.h | 6 ++++++ kernel/livepatch/transition.c | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index adca5cf07f7e..b716a6289204 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -554,7 +554,7 @@ static int klp_add_nops(struct klp_patch *patch) struct klp_patch *old_patch; struct klp_object *old_obj; - list_for_each_entry(old_patch, &klp_patches, list) { + klp_for_each_patch(old_patch) { klp_for_each_object(old_patch, old_obj) { int err; @@ -1089,7 +1089,7 @@ void klp_discard_replaced_patches(struct klp_patch *new_patch) { struct klp_patch *old_patch, *tmp_patch; - list_for_each_entry_safe(old_patch, tmp_patch, &klp_patches, list) { + klp_for_each_patch_safe(old_patch, tmp_patch) { if (old_patch == new_patch) return; @@ -1133,7 +1133,7 @@ static void klp_cleanup_module_patches_limited(struct module *mod, struct klp_patch *patch; struct klp_object *obj; - list_for_each_entry(patch, &klp_patches, list) { + klp_for_each_patch(patch) { if (patch == limit) break; @@ -1180,7 +1180,7 @@ int klp_module_coming(struct module *mod) */ mod->klp_alive = true; - list_for_each_entry(patch, &klp_patches, list) { + klp_for_each_patch(patch) { klp_for_each_object(patch, obj) { if (!klp_is_module(obj) || strcmp(obj->name, mod->name)) continue; diff --git a/kernel/livepatch/core.h b/kernel/livepatch/core.h index e6200f38701f..ec43a40b853f 100644 --- a/kernel/livepatch/core.h +++ b/kernel/livepatch/core.h @@ -7,6 +7,12 @@ extern struct mutex klp_mutex; extern struct list_head klp_patches; +#define klp_for_each_patch_safe(patch, tmp_patch) \ + list_for_each_entry_safe(patch, tmp_patch, &klp_patches, list) + +#define klp_for_each_patch(patch) \ + list_for_each_entry(patch, &klp_patches, list) + void klp_free_patch_start(struct klp_patch *patch); void klp_discard_replaced_patches(struct klp_patch *new_patch); void klp_discard_nops(struct klp_patch *new_patch); diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c index 300273819674..a3a6f32c6fd0 100644 --- a/kernel/livepatch/transition.c +++ b/kernel/livepatch/transition.c @@ -642,6 +642,6 @@ void klp_force_transition(void) for_each_possible_cpu(cpu) klp_update_patch_state(idle_task(cpu)); - list_for_each_entry(patch, &klp_patches, list) + klp_for_each_patch(patch) patch->forced = true; } -- 2.13.7