From patchwork Thu Oct 10 20:19:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heitor Alves de Siqueira X-Patchwork-Id: 1174791 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46q2WF0Xycz9s7T; Fri, 11 Oct 2019 07:19:53 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1iIeuZ-0005ri-Sa; Thu, 10 Oct 2019 20:19:47 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iIeuY-0005rW-8e for kernel-team@lists.ubuntu.com; Thu, 10 Oct 2019 20:19:46 +0000 Received: from mail-qt1-f199.google.com ([209.85.160.199]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iIeuY-0008Cl-1N for kernel-team@lists.ubuntu.com; Thu, 10 Oct 2019 20:19:46 +0000 Received: by mail-qt1-f199.google.com with SMTP id t25so6992002qtq.9 for ; Thu, 10 Oct 2019 13:19:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=lg6u2adNunonLSu3/smhuYQxN+RWOaMPYWN4Urm9rOM=; b=DXp4tuTJYj+YSMvVGsAgVigz0RqZcDbjynRWkFm5kfUr6GvMnsIsRkWHVq2qEYKeac LEWBkvCy7agxXlxp8wHTZYi45DeaeIhkyWBPFPMHtXV0sIeNxCnKZNAFXwaSAGQXjvm8 UtzPnGMLjgmzdfxVjdcNVVkWJjbeguF8uVWLQPqz2Er2YdGEOqgY4jH1c9t0Pu7xsLZH XbTzKBFfJkahBdebB8xs516En+vCERPTcHexkiHrdGUdVsFu4VF5qqCBbLSiXDNlurUa rS453zVBAvp1SGRqGyNEkwYbahFDhZFi/NPYucU4bk4NAwzEmY5muROuv5gn3yRi3wvf 4o7w== X-Gm-Message-State: APjAAAVuvqD6Oqxu0u1e433J4IhfQqi0RhEvlN311/7maTsEJk9JcnDS g5uJ/poFGTnGiRXU9pIk9LDpvnEvSANPGRn/fixKbF4NQtauodzKQbpisyAdEIgP+dDtxts/KdI /zE+d8qi2A3FP9C1GCbB2dd04T7M2Z1/RgfIKgfn82A== X-Received: by 2002:a0c:95a5:: with SMTP id s34mr12237892qvs.72.1570738784898; Thu, 10 Oct 2019 13:19:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXbcJv9tU4V5BuZRlX/uf2JUK4nbw8Q0YPeEtn+htk6UutIMABx8CrgKeUX6RWiS2543Vr3A== X-Received: by 2002:a0c:95a5:: with SMTP id s34mr12237868qvs.72.1570738784586; Thu, 10 Oct 2019 13:19:44 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:4e3:8352:edf7:8648:100d:9be9]) by smtp.gmail.com with ESMTPSA id 207sm2447765qkh.33.2019.10.10.13.19.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 13:19:44 -0700 (PDT) From: Heitor Alves de Siqueira To: kernel-team@lists.ubuntu.com Subject: [PATCH 0/1][SRU][X/B/D/E] Fix bcache performance degradation when querying priority_stats Date: Thu, 10 Oct 2019 17:19:38 -0300 Message-Id: <20191010201940.30382-1-halves@canonical.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1840043 [Impact] Querying bcache's priority_stats attribute in sysfs causes severe performance degradation for read/write workloads and occasional system stalls [Test Case] Note: As the sorting step has the most noticeable performance impact, the test case below pins a workload and the sysfs query to the same CPU. CPU contention issues still occur without any pinning, this just removes the scheduling factor of landing in different CPUs and affecting different tasks. 1) Start a read/write workload on the bcache device with e.g. fio or dd, pinned to a certain CPU: # taskset 0x10 dd if=/dev/zero of=/dev/bcache0 bs=4k status=progress 2) Start a sysfs query loop for the priority_stats attribute pinned to the same CPU: # for i in {1..100000}; do taskset 0x10 cat # /sys/fs/bcache/*/cache0/priority_stats > /dev/null; done 3) Monitor the read/write workload for any performance impact [Fix] To fix CPU contention and performance impact, a cond_resched() call is introduced in the priority_stats sort comparison. [Regression Potential] Regression potential is low, as the change is confined to the priority_stats sysfs query. In cases where frequent queries to bcache priority_stats take place (e.g. node_exporter), the impact should be more noticeable as those could now take a bit longer to complete. A regression due to this patch would most likely show up as a performance degradation in bcache-focused workloads. Shile Zhang (1): bcache: add cond_resched() in __bch_cache_cmp() drivers/md/bcache/sysfs.c | 1 + 1 file changed, 1 insertion(+) Acked-by: Connor Kuehl Acked-by: Kleber Sacilotto de Souza