Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1213117imu; Wed, 16 Jan 2019 14:57:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN5+XWfyV2cKSAdqC/U7ObTFOD551bs3oe+MNakzOAQXsll/yioqEXg6CtxwrHTDlfZOgXSp X-Received: by 2002:a63:6f0d:: with SMTP id k13mr11071051pgc.42.1547679439358; Wed, 16 Jan 2019 14:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547679439; cv=none; d=google.com; s=arc-20160816; b=bxO3vqQY1n0RxseB7ZL/l9aWQK7Cd2UKU7KjrnAjPX5Sowhtw/fmE/9CzmOnTIwCpS PIVoV+LdYcd+O/Wob2ORF10K5CpMfzkPPwYmQVhDC9aOU2aZeCJUQUCmU+/Rdz09UTmP PFVUcS+OZat7xKsuucXd9nh68i7kEX1oGIiK1S2aYCVOrNVVdmV9bHDrQa8MVMVW3mtQ xt1f+nVn7wMFWwuM+h8pyxCrbJyLxjQjb4cITSsUZVnCakFB6huV1w3cUPidQn/Idpm0 zPbjHDU5UYq4Bh6ZKz4skYF4Rj9LR9ddQXgC0lRM/aRpOBrUPXdBATsU/HH8+vfCqisP aPcQ== 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=Pl39D6xR6rDtUIT0z+vjhc38T0IHVTMFvrFxjx3oPMA=; b=mBzpA4ppssQ2QkfVp6YuHjY4rVxPfkCCHPV4Xii6hUoYx5ad5XTX+sxLtjmpqzhWYg PCshcgSAMOnwz6ON9ug95KsjdDyApeiVeerQRroK8/W8zZKVQ1RDSL3c5TNBZ5zrzIFz 533JqINSTuUoMt722UWX0IYGTWFUvMa1oQ7zuWqLHDnKtlGg3el8PeM2+aVR2H5gmGXA z/xVkwDoVwZDmYA28JuUfByCzmW6FmLiNebtUna8o9YKOOeXmAyWBihChDSrW20tFCL8 137yEEWc4Uh+lDG/ohLgBQkRX7uohMkFeUiZS7o2tVKiqDfz7TKof94Csh689UHPfAsH VSMQ== 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 n24si7041195pgv.119.2019.01.16.14.57.01; Wed, 16 Jan 2019 14:57:19 -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 S2405225AbfAPQRr (ORCPT + 99 others); Wed, 16 Jan 2019 11:17:47 -0500 Received: from mx2.suse.de ([195.135.220.15]:38666 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729517AbfAPQRq (ORCPT ); Wed, 16 Jan 2019 11:17:46 -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 73911AE3C; Wed, 16 Jan 2019 16:17:45 +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 1/4] livepatch: Introduce klp_for_each_patch macro Date: Wed, 16 Jan 2019 17:17:17 +0100 Message-Id: <20190116161720.796-2-pmladek@suse.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20190116161720.796-1-pmladek@suse.com> References: <20190116161720.796-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 --- 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