From patchwork Thu Apr 19 10:58:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 133745 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp490246ljf; Thu, 19 Apr 2018 03:59:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx48mxj8N+arh69B/Cw3IKsTeD5KVXduRoVFn78RGiY+aYiZyZRU8usmt//mf0nLylT/4rIVY X-Received: by 2002:a17:902:6909:: with SMTP id j9-v6mr5691642plk.313.1524135541061; Thu, 19 Apr 2018 03:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524135541; cv=none; d=google.com; s=arc-20160816; b=YLLdyfXgWaSb8aqE3YwH715Bu94Iziv5BXwUyerB1hImtwtcgJ5voykXt0Aq9z53a+ AFoy3flNVwlhLPoGa2pZMpaz7nA2KYbEcgoQj9pAI8HZorrX+g3AhEs/zf3IhoufGzas 7gx2ME8nQY41mY1NToaMx9aqZlPtjAOIhAvsjWp32ttdZxCCkvxZwidJdWskucYgK+AM R40YJTkCdcMHko9iGcMufrbO+kMfmeDFEOa7tPHgLDn4ExqIAaMsb3m4f49D/PVqMznS NE3DcuC1JbnUwhndzPfYjtxGk8v4PQcELRa7CZ8IBr47Lpk5hEoxtyRJ6oJtgHCuLiMj khMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=K/DK/3nk9ldL85mUvosbWoGMSQ7DkLH51QA3YNKR3Rk=; b=qxfUCiEBcW75wWnzwdQ3fLyBb9VUp7jvPqz6nKy4tyiJhBZt/9gBfO0VAfPTLKnOy6 orFBvBGgCGrLgMFrAEt1bGSV5VhgOfmq56mcLuZ008SMC2LnroAFEc7nOTGbYjEJT7DG gzslDOtI2kO5pFJkuNMeyOh2ZnkK5RAJGOV09i722Ap83Hk89uI0+0RRYqr1hMLOXpLa uo0kS+P9H460DdVn8GhtOsbtzqLpoKVpd8PL3zaBfWekPJEiqOZfBls1zdKXLlsPa8Oe MEExUrFgS5Obe2g9IBLA2X/ctwap4O9BEdMCkzhLPnDweotEpAvnKWHdbF7CL+2uuSPw ILsg== 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 z6-v6si3101456pln.339.2018.04.19.03.59.00; Thu, 19 Apr 2018 03:59:01 -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 S1752496AbeDSK65 (ORCPT + 29 others); Thu, 19 Apr 2018 06:58:57 -0400 Received: from foss.arm.com ([217.140.101.70]:35792 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751228AbeDSK6z (ORCPT ); Thu, 19 Apr 2018 06:58:55 -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 2787280D; Thu, 19 Apr 2018 03:58:55 -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 E4AB23F59D; Thu, 19 Apr 2018 03:58:52 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Ralf Baechle , James Hogan , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , "David S. Miller" , Ingo Molnar , Peter Zijlstra , Steven Rostedt , Oleg Nesterov , linux-arch@vger.kernel.org Subject: [RFC PATCH 0/6] Simplify setting thread flags to a particular value Date: Thu, 19 Apr 2018 11:58:42 +0100 Message-Id: <1524135528-28561-1-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 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) See patch 1 for details. Reviewers please pay close attention to accidental conversion of set_tsk_thread_flag() to set_thread_flag() for example, and accidental inversion of conditions. I'm pretty sure neither happens, but build-testing can't pick these up. Build-tested on x86 and the explicitly patched architectures (defconfig and multi_v7_defconfig for arm, defconfig for arm64, mips, powerpc, sparc). Boot-tested on arm64, with some context-switch stress tests that depend on correct maintenance of TIF_FOREIGN_FPSTATE. Background rationale: I've found myself coding this idiom a few times now and would like to stop duplicating it. Using an ungainly lash-up of sed and grep I tried to find other users of the same idiom without too many false positives, and there while there aren't a huge number it seemed enough to be worth having a go at a simple cleanup. The core changes are in the first patch; other changes are split per-arch. Dave Martin (6): thread_info: Add update_thread_flag() helpers ARM: Use update_thread_flag() arm64: Use update{,_tsk}_thread_flag() MIPS: Use update{,_tsk}_thread_flag() powerpc: Use update_thread_flag() sparc: Use update_thread_flag() arch/arm/kernel/elf.c | 9 +++------ arch/arm64/kernel/fpsimd.c | 19 +++++++------------ arch/mips/kernel/elf.c | 10 ++-------- arch/mips/kernel/process.c | 15 ++++++--------- arch/mips/kernel/ptrace.c | 5 +---- arch/mips/kernel/syscall.c | 10 ++-------- arch/powerpc/include/asm/elf.h | 10 ++-------- arch/sparc/include/asm/elf_64.h | 5 +---- include/linux/sched.h | 6 ++++++ include/linux/thread_info.h | 11 +++++++++++ include/trace/syscall.h | 6 ++---- kernel/ptrace.c | 13 +++++-------- 12 files changed, 48 insertions(+), 71 deletions(-) -- 2.1.4