Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp981451imm; Wed, 1 Aug 2018 08:18:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdzxbGw2JhVZvYubCfZEeZ3UlsdkqX/5YyQ666APfo8MiMM7fu1VM6uOUBL+13uTDoaCee9 X-Received: by 2002:a65:60cd:: with SMTP id r13-v6mr25040531pgv.232.1533136733201; Wed, 01 Aug 2018 08:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533136733; cv=none; d=google.com; s=arc-20160816; b=r+Z834sVxYLJvJDYcKnZfT0FZmyMWS3pwDLpIhzRSwc0PrJVhA+w5S/lHulUy5vWMx 9EsLA8/dqXKqXbq/eqL7chtk6G8PR7R38WGvpJSVbBwh1kaBS2AS7Ln0srxpBHqEc2mI hHW68vNYpgK0Wl+t7KKLUiu3u+Ok3aF5UtyhAceeGERjNcsVa6H1KzWCl7uT7tSFQqRz 2Ow4IIkNOY9uLTAaafu/xexY5d6C/zVNAbIVIycK2jpqN3HBlZJFS0TLtO3q8brGqqEG JhBf0/kHzR7DYlQaW/3Dvk5ID4TTFic763F7qTsDj1eYou8yUToXfvapIYmnBBVvgXiG GBrg== 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:dkim-signature:arc-authentication-results; bh=EOH4yuXU61UFUoCxssnGS0E9pmyAjCBzpOCJhmVNCYY=; b=0w7xGqFZkmmvPiBqB3muqb33rgocaYT06Y+xeP46Bh+EVy0OHMcD41VErDfcBsQ0VF 2wZjGaeqixXN88fCUo3HFJ+wFcn4xKrJ83QP7Ch7egb4tZ24OVs2ZC3kqcWEgp716pfU ZuvwdLUbVnx3aEQ81Uf7XrKZeIsikfxTEE91uU5ddWQbwBJqmTZjMnNzRJJ1QonC/3hg qAJYWUcNVmbCz6rrcCbEVWCaM6++RbxHM/R8JgmlMRBPdXvGmELeeCIkdbc0SAb4dgHK jL/BfiH04ITG8GKboBs92P7N6ATYLyRfeqvqyt9Vt2RUrvwy2KQf8ZqqogS+RpH22iMS uh1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=YMeIfO7c; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s199-v6si18240577pfs.255.2018.08.01.08.18.38; Wed, 01 Aug 2018 08:18:53 -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; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=YMeIfO7c; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389830AbeHARDq (ORCPT + 99 others); Wed, 1 Aug 2018 13:03:46 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35075 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389806AbeHARDp (ORCPT ); Wed, 1 Aug 2018 13:03:45 -0400 Received: by mail-qt0-f193.google.com with SMTP id a5-v6so20262699qtp.2 for ; Wed, 01 Aug 2018 08:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EOH4yuXU61UFUoCxssnGS0E9pmyAjCBzpOCJhmVNCYY=; b=YMeIfO7cHaOPiMpMbEL3NOKawxOjbeGFP0k9cxcW/u73CdC8UdEjGti+n/J1hepbbL zC9EPQ6M3PsLnBBXu7zrA5qGMcnCgHgagLN5jzI9+SmcImMJ961PzYjpSy45FkXX0JZw 0eAz+TM8bpe3OY27wnif6jAJ8/W4uBGXYf3fvtSHMoZ0RqTjQt589ELUAgAfzwQ2ojr+ jkjjPbmQoZ9q0yzFS9xHB+gBuD9Lvz9GjaGpD1GL9Bvs1M/hMOlWdjgmBnGYs5V2O6SN YNN1XzVzvzPZx98pl+pkHX8yqqelvVMDJ+ZoYPpNA5PyWTg8YW5QcvjCMws1CkX9fo8r xyPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EOH4yuXU61UFUoCxssnGS0E9pmyAjCBzpOCJhmVNCYY=; b=ceFvA2yJjoiVpamNEfZJPSZaUf/5OdpaCIGSSZC8Is03SLCTMm/vWfeE57a5xRR+o6 N3pp8BBXnNeYqaykSMAqt9bm6twYxUH/j/DNDbHOmbMK3Nke665/K4yBTut1pJNoaTMG UQxNwLyW9BKXsza7jYQpqYKzJkSMfVU3IFaewCsIUjkBAYORVCuNf/2dE8CJknhXMswD JPn3emKMhr3ro0HtqEaZqCBi+RMJF3o3im3FvQqW8GRGw/KRqVyAQ7Sn9VAbxnyIKEr/ 4eOcdf4Wmq8/FtRSsipuKVnuoF5oe12ZhMthcjwCwu8vKQLiCV3Rf66jalpwfjqfiVbs DeTg== X-Gm-Message-State: AOUpUlHdMkIjD8h0ShivMZ88QEfoTzj94VsKLQHqyfhc7YYgdLDS+N6V frTwVbLtn1sEWe34mKofnlU9jc4227k= X-Received: by 2002:a0c:f8ce:: with SMTP id h14-v6mr23582982qvo.163.1533136654208; Wed, 01 Aug 2018 08:17:34 -0700 (PDT) Received: from localhost (216.49.36.201.res-cmts.bus.ptd.net. [216.49.36.201]) by smtp.gmail.com with ESMTPSA id k38-v6sm13787746qtc.45.2018.08.01.08.17.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 08:17:33 -0700 (PDT) From: Johannes Weiner To: Ingo Molnar , Peter Zijlstra , Andrew Morton , Linus Torvalds Cc: Tejun Heo , Suren Baghdasaryan , Daniel Drake , Vinayak Menon , Christopher Lameter , Mike Galbraith , Shakeel Butt , Peter Enderborg , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 7/9] sched: introduce this_rq_lock_irq() Date: Wed, 1 Aug 2018 11:19:56 -0400 Message-Id: <20180801151958.32590-8-hannes@cmpxchg.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801151958.32590-1-hannes@cmpxchg.org> References: <20180801151958.32590-1-hannes@cmpxchg.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org do_sched_yield() disables IRQs, looks up this_rq() and locks it. The next patch is adding another site with the same pattern, so provide a convenience function for it. Signed-off-by: Johannes Weiner --- kernel/sched/core.c | 4 +--- kernel/sched/sched.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 211890edf37e..9586a8141f16 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4960,9 +4960,7 @@ static void do_sched_yield(void) struct rq_flags rf; struct rq *rq; - local_irq_disable(); - rq = this_rq(); - rq_lock(rq, &rf); + rq = this_rq_lock_irq(&rf); schedstat_inc(rq->yld_count); current->sched_class->yield_task(rq); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index b8f038497240..bc798c7cb4d4 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1119,6 +1119,18 @@ rq_unlock(struct rq *rq, struct rq_flags *rf) raw_spin_unlock(&rq->lock); } +static inline struct rq * +this_rq_lock_irq(struct rq_flags *rf) + __acquires(rq->lock) +{ + struct rq *rq; + + local_irq_disable(); + rq = this_rq(); + rq_lock(rq, rf); + return rq; +} + #ifdef CONFIG_NUMA enum numa_topology_type { NUMA_DIRECT, -- 2.18.0