From patchwork Fri Mar 17 13:44:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 13179070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6125C74A5B for ; Fri, 17 Mar 2023 13:50:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CFE56B0074; Fri, 17 Mar 2023 09:50:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 680406B0075; Fri, 17 Mar 2023 09:50:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 548996B0078; Fri, 17 Mar 2023 09:50:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 456926B0074 for ; Fri, 17 Mar 2023 09:50:34 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 14C5B121867 for ; Fri, 17 Mar 2023 13:50:34 +0000 (UTC) X-FDA: 80578525188.07.EAFF698 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf26.hostedemail.com (Postfix) with ESMTP id 46C0C14000A for ; Fri, 17 Mar 2023 13:50:31 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf26.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679061032; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YezikHQUygm0KAkzKI4mrR3/7OjNf8PCGFqoeYhJShw=; b=MYDjxXWqCQDa4CZQlsEnF2mL5a+Liqmyk8UU328CBRbxUDsXvXaeaRceW2QjTvta0t2LvE 6/nuZpJfTIHbVLZHdOygxMvRPvfMTKvpAxMGb/Z9g+puhmvdZAzMMeYP1GDdEHQZUeZdVV 71RqUEz0Gmn9cnibP05xwtncOv0XY1Y= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf26.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679061032; a=rsa-sha256; cv=none; b=3v2cOTab8kXYqlcKiD4rxmML30IUm6CZJDLy4TjewoQtm/s4IxMq6DP3KMd1Nsrv4tcpgU 05bicl5l/AgL4eC6Xx9yacXj6OCVrWWfgM9+u6mIBgObfW9QVJk+kl0D5jquPtqwzhoQO5 7gK8GruTta1WWDR5gD4X6OLOnZaQKiM= Received: by mail-ed1-f44.google.com with SMTP id fd5so20596710edb.7 for ; Fri, 17 Mar 2023 06:50:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679061030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YezikHQUygm0KAkzKI4mrR3/7OjNf8PCGFqoeYhJShw=; b=sMolyNwzysTOHa+RkYeOX1zKBU1+GXsnY3vHKvWmrLyLQJQjoi0EP7G0Yl0CkcnrQM DUTj+786MStY+zJ4uaUU2w7tM7AYr2xfNjCHFRHQYa+ao8+elhk0g2fqpES6LomPXdEc hBBgWPHdMJ8xwn7j2h5Y9hyJ0X9QHPaqD7+GHck40uZFXgrVZMz82W2tv2/rVTv5joT9 gJVlnaH3o5ptLZct3os7jWzmZ/YsuYrkDJYz+NuvaqHaa9dQaPfG1E4756OYftlDcrzg 864vSFBvgHX6ijsv5MacH+eObD0sXOksOgxH8+IcwXLv2EGLa23ah6msmIvIpjn60ad9 W1ag== X-Gm-Message-State: AO0yUKW1w9J7t9cTkEDRG51xWYATT8r6OqlJEi8PPis0QglYvZfPuMKQ YD7oeO++gfW3v/yOchetPFg/+bAQWO0= X-Google-Smtp-Source: AK7set8W6CBQK9DHME/oMj44VdHDuWDaYeldL0uT0YRT9PqS8dczD/Fs05iiv7KqmxIKgTa6EaVd8A== X-Received: by 2002:a17:906:2645:b0:882:ed4a:f23 with SMTP id i5-20020a170906264500b00882ed4a0f23mr13791775ejc.49.1679060693197; Fri, 17 Mar 2023 06:44:53 -0700 (PDT) Received: from localhost.localdomain (85-160-41-201.reb.o2.cz. [85.160.41.201]) by smtp.gmail.com with ESMTPSA id gz14-20020a170906f2ce00b00923221f4062sm999273ejb.112.2023.03.17.06.44.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 06:44:52 -0700 (PDT) From: Michal Hocko To: Andrew Morton , Leonardo Bras Cc: Frederic Weisbecker , Peter Zijlstra , Thomas Gleixner , Marcelo Tosatti , Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , LKML , , Frederic Weisbecker , Michal Hocko Subject: [PATCH 1/2] sched/isolation: Add cpu_is_isolated() API Date: Fri, 17 Mar 2023 14:44:47 +0100 Message-Id: <20230317134448.11082-2-mhocko@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230317134448.11082-1-mhocko@kernel.org> References: <20230317134448.11082-1-mhocko@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 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om EVL+QIzh ZXGOXsNMCnVtxH27eALilO/szUF/kfvh2Zwbpq09yKrV1++bnwBVVAjaixIQ6TAVExBxnPyPelyw5BO5UGHV8a0a3A6p1ujFnRe+qi0cfn9RR4dvlBB7oSyjmWvQlVRIrEjEnA2pNZTCjzeWp4qDws4W57qDRctuKsLb20fzBwMWMqBrk/Q7h9uLRPJUX87mUn+3VCvE86j3UeTn5y+5rZDPV1y7+tS595Y2+k+C4rhijLq8OrpTO9bV0ebEYN4za+c76TyR28Cwj1FsCYBxDinoIi3+yeKgcNjw+w3HUU4BfCtUFZz+80D3U6+noTbMbsl49O36yhEEcY4hmaLwM9H18dyQ32Mmcrjbc6xZ/RuS3wyVttdJlY2FQlUDmBcnqU3r7rxFqK8X1e4O9BJTBc0kVdiQSZj1ftORqAQym8Rk2DFjk4Rinb8/p79w9YmGt3fJ25U1t0DDNYb4bJ5PgAyyVAFIcGNjD3mKZvVxnuR10ODHeNn6SHXeqxUBPH18+AL7Q/a9in9vPbvn8j3BLxdrQ0PyUTTf7BfOqnRAqn7TX5hTPpE1DfjSFC+Rw79PdUxQrQDDMwosGAMaHfB3C7F1aoEWFq/L6x93dCV6SwgoImaJFuL5PJHIARtDvauTP5E4X X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Frederic Weisbecker Provide this new API to check if a CPU has been isolated either through isolcpus= or nohz_full= kernel parameter. It aims at avoiding kernel load deemed to be safely spared on CPUs running sensitive workload that can't bear any disturbance, such as pcp cache draining. Suggested-by: Michal Hocko Signed-off-by: Frederic Weisbecker Signed-off-by: Michal Hocko --- include/linux/sched/isolation.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h index 8c15abd67aed..fe1a46f30d24 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -46,6 +46,12 @@ static inline bool housekeeping_enabled(enum hk_type type) static inline void housekeeping_affine(struct task_struct *t, enum hk_type type) { } + +static inline bool housekeeping_test_cpu(int cpu, enum hk_type type) +{ + return true; +} + static inline void housekeeping_init(void) { } #endif /* CONFIG_CPU_ISOLATION */ @@ -58,4 +64,10 @@ static inline bool housekeeping_cpu(int cpu, enum hk_type type) return true; } +static inline bool cpu_is_isolated(int cpu) +{ + return !housekeeping_test_cpu(cpu, HK_TYPE_DOMAIN) || + !housekeeping_test_cpu(cpu, HK_TYPE_TICK); +} + #endif /* _LINUX_SCHED_ISOLATION_H */