From patchwork Fri May 4 16:05:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 134983 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp224067lji; Fri, 4 May 2018 09:05:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrB9W53MX5DgPb/PdG2CgDtYD6pXgwntUm7AzZvYZaXulcjjZAmJ3vUbXYxonQBDd36mVUy X-Received: by 2002:a63:3286:: with SMTP id y128-v6mr23356459pgy.419.1525449950920; Fri, 04 May 2018 09:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525449950; cv=none; d=google.com; s=arc-20160816; b=1DRhpXsAvPaIAnkLQlQb+bZn+BPKP47j05nHYAxKUuH8iwv23Stj0+qGY+SCQE79Rl 31evwx3/JH04ysiN0B1qC+x3WPWaNnEufjCaB7NOXgXYXqq7JcRznU6nVGGGgX3hVCCI sAck+CJkU5kRFR3bM4tK7plM4VWDFD/u+CFGLLdvVqExg+UN/h5FHsYnHx5podJc+6s3 ypxb18IDo1wZZvWiuotZgz9JisHsKIdgXQyC9Sh/bbsesw624c+K6nzgoIiKJdq36ufZ BJcYQ50Lvay0t1Eu1GCYCUVq3e9dhAnM3KJjDSooqbx0Njd2emh0CPP6S4rGQ6q3M+Gx x3hg== 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:arc-authentication-results; bh=9Nou9GIVhqyeRC+teJq6RxWlliMq8lsVRRg1yxVUwno=; b=BuwqmD+WQ06WGwjnAiZFkpvch7qaI7Q0KDyIxO9AUKGM7F53ag4/8mRqoa2PMC7T4S Nsc6o5djdcKHojTrLQr4TyVuNVnpYC7mpsEhUCT+te0nx7yEROx73GNy9Ia/PvuZu3Vs ItZ+p6Watm0NJtlNjPDB2GGaVQsj4hKBD+QgisDepkWnMk27eGXfT49MGoo6VcvXuJpC r2o8Q+RNDUzNxtCP2Z90R6w2pq9yft0Jr/yS+WQz2Gu94KVq9QZdKOgVLj6nMFoC7O8A GWLQqlGr2stinRURvDmwFsyjzvirZRyWigoKdQ6XuFpHlobWvDknyyXOE5YuQbDt7jPf WNHA== 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 s67-v6si6997749pgc.204.2018.05.04.09.05.50; Fri, 04 May 2018 09:05:50 -0700 (PDT) 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 S1751776AbeEDQFr (ORCPT + 29 others); Fri, 4 May 2018 12:05:47 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:55618 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751229AbeEDQFn (ORCPT ); Fri, 4 May 2018 12:05:43 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6162F1596; Fri, 4 May 2018 09:05:43 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 73C533F25D; Fri, 4 May 2018 09:05:41 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, Christoffer Dall , Marc Zyngier , Ard Biesheuvel , Catalin Marinas , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Steven Rostedt , Oleg Nesterov Subject: [PATCH v5 01/14] thread_info: Add update_thread_flag() helpers Date: Fri, 4 May 2018 17:05:22 +0100 Message-Id: <1525449935-31424-2-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1525449935-31424-1-git-send-email-Dave.Martin@arm.com> References: <1525449935-31424-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are a number of bits of code sprinkled around the kernel to set a thread flag if a certain condition is true, and clear it otherwise. To help make those call sites terser and less cumbersome, this patch adds a new family of thread flag manipulators update*_thread_flag([...,] flag, cond) which do the equivalent of: if (cond) set*_thread_flag([...,] flag); else clear*_thread_flag([...,] flag); Signed-off-by: Dave Martin Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Oleg Nesterov --- include/linux/sched.h | 6 ++++++ include/linux/thread_info.h | 11 +++++++++++ 2 files changed, 17 insertions(+) -- 2.1.4 diff --git a/include/linux/sched.h b/include/linux/sched.h index b3d697f..c2c3051 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1578,6 +1578,12 @@ static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag) clear_ti_thread_flag(task_thread_info(tsk), flag); } +static inline void update_tsk_thread_flag(struct task_struct *tsk, int flag, + bool value) +{ + update_ti_thread_flag(task_thread_info(tsk), flag, value); +} + static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag) { return test_and_set_ti_thread_flag(task_thread_info(tsk), flag); diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index cf2862b..8d8821b 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -60,6 +60,15 @@ static inline void clear_ti_thread_flag(struct thread_info *ti, int flag) clear_bit(flag, (unsigned long *)&ti->flags); } +static inline void update_ti_thread_flag(struct thread_info *ti, int flag, + bool value) +{ + if (value) + set_ti_thread_flag(ti, flag); + else + clear_ti_thread_flag(ti, flag); +} + static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag) { return test_and_set_bit(flag, (unsigned long *)&ti->flags); @@ -79,6 +88,8 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag) set_ti_thread_flag(current_thread_info(), flag) #define clear_thread_flag(flag) \ clear_ti_thread_flag(current_thread_info(), flag) +#define update_thread_flag(flag, value) \ + update_ti_thread_flag(current_thread_info(), flag, value) #define test_and_set_thread_flag(flag) \ test_and_set_ti_thread_flag(current_thread_info(), flag) #define test_and_clear_thread_flag(flag) \