Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp475163imc; Sun, 10 Mar 2019 11:14:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYVq9kjBBN+DY738fBpir8+Adp2dmig0GhO9twesoRzwJ9rV0j5hz6FXauyilu2unPSf9u X-Received: by 2002:a17:902:b609:: with SMTP id b9mr30111977pls.134.1552241643451; Sun, 10 Mar 2019 11:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552241643; cv=none; d=google.com; s=arc-20160816; b=a7HEd7Fh4Gpiv/T0H24iIjnRCKIkL92693hl3DYPkr5ZvPAM1hGg9KHjOLNyOra5VI CNvQw6cKGVAtSrgequpOkTW401+CJyP8LmVlFhRJ/jP4p7S0gLQVpqgk2C4f7QvFioAD Zl/KkKvZCYDJPKS5bE4gZM53yaoTrDzJSbNPfUIljX0mT8GAPRdXNFrS4sQYYN95JtC4 g0SdMDFhfHzkBRRYADDZaOBO8BNXwuT7avAEAYtzOByh1eYQREDtAFcD2a4spcbYdCJA Vdh5jCBR3FgDRh9A8Skgz2bCuPbX0hr0k0F/jkq12FBSxvTcnzh05K1niXWYT1Ppim1j 7x3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rzi6we5rwF3Y64l19PsLoFd2B5RuM9WGk0GjrjaWejk=; b=z3W2fWPhZ3wUOLUsscGu2m5Q1nPAxtJ9eVcm99u0fT3KgAxvUCtxq0NgAQ0HUinCGt YwM+TxOclWNccAFPEFCEIjcJXpXtehKN4BIcbx1fct3BcZaX1YDBBU+jEalTQg99NZon hdFAJJRZ/NgbI7SAGtWTNgimiE/YFNNIipEsib3i1bp9NgNudgRmJFZYB0lzQ1F/Tum+ +bHA+YTlL/tt5/fuyOJoQMwaTHvmguSy6UdRKkLIrRZ7ywyAUxMAOjrZCY6WTNmKA+EF GI2/CUIfaT4E5HqrBEhlNgCAtA2HjwSgYBnB2YaC8x7VQ/0ccQgNxLoRG1C/fbZuxgJA 0v6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QippPLGl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si3450437pln.72.2019.03.10.11.13.48; Sun, 10 Mar 2019 11:14:03 -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=@linaro.org header.s=google header.b=QippPLGl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727007AbfCJSMo (ORCPT + 99 others); Sun, 10 Mar 2019 14:12:44 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39524 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726945AbfCJSM0 (ORCPT ); Sun, 10 Mar 2019 14:12:26 -0400 Received: by mail-wr1-f68.google.com with SMTP id p8so1036910wrq.6 for ; Sun, 10 Mar 2019 11:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rzi6we5rwF3Y64l19PsLoFd2B5RuM9WGk0GjrjaWejk=; b=QippPLGlc/JE4mt1hPQnApMT6VQ2+P2ihx/NcxK9/f1FpFPKP6s5TLVUVYacaKqkkC 6ebcAHsbiy82QhweTPwXTB/zkESgxYcXWN553XYhhc6OOAQzfid12lBW6S3VvuwB7C0W ZFRop+pnOxeU3G3u7OIoMC4COenmsodLBR0srU32+t6oZ+GBBVIVoFE1phTqrZhzjKPR qVkIo2nkL6qfuXTYFUxwUZX85iDscB7A6ivF062zY3zDhCjRxJOs/W6teMBfpT/msHii cSnGfOX4CNw45oQ5vfZd+0sD2U5CP8dRhrTgLGrw+dqn1pe8U/Jor5QQeGdGHKH8s4L+ 0g/A== 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:mime-version:content-transfer-encoding; bh=Rzi6we5rwF3Y64l19PsLoFd2B5RuM9WGk0GjrjaWejk=; b=SvZ7p5tt9vATBzMOLcjpB/wgCn+wKcLERtvNTy6MMsadNZfVns/iBvgouGllgLNqoN DVqQKnfq1QoIZyq+W3GK+W0boUOetxbiAiCgeH2KhkxIT4Ct5Xbd5CqmerUlfmd+STVB y8MsKfc9YW8lyVUWW4VA8JLZLJSJG1xXI15Gxvll44y/ZLkEiL6BDVrLqviHJMZw7IpZ wjxyGGwp0RsUpaFt2KqcFr3S26O4e0Dtik1OqCnzYh16SA8Z77eQCnLAw9uKXOZ6s3Cs NOhIyRseRoFzTHrjJH7JsrHdLcaA8v/yd9GKF2DWnt/EBQFjaYoJKdF5VF8Ss9+c1K/W 2xAw== X-Gm-Message-State: APjAAAX45eWY8YoQ2Uusu+q30rUFOyKqKsgVkch9oubvKqetg/BaQ4El ixeoA9NpLpNcDNnXm6X33pJnUQ== X-Received: by 2002:adf:ec41:: with SMTP id w1mr18411906wrn.184.1552241544158; Sun, 10 Mar 2019 11:12:24 -0700 (PDT) Received: from localhost.localdomain (146-241-67-113.dyn.eolo.it. [146.241.67.113]) by smtp.gmail.com with ESMTPSA id d206sm24906368wmc.11.2019.03.10.11.12.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Mar 2019 11:12:23 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, fra.fra.800@gmail.com, alessio.masola@gmail.com, Paolo Valente Subject: [PATCH BUGFIX IMPROVEMENT V2 7/9] block, bfq: print SHARED instead of pid for shared queues in logs Date: Sun, 10 Mar 2019 19:11:35 +0100 Message-Id: <20190310181137.2604-8-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190310181137.2604-1-paolo.valente@linaro.org> References: <20190310181137.2604-1-paolo.valente@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Francesco Pollicino The function "bfq_log_bfqq" prints the pid of the process associated with the queue passed as input. Unfortunately, if the queue is shared, then more than one process is associated with the queue. The pid that gets printed in this case is the pid of one of the associated processes. Which process gets printed depends on the exact sequence of merge events the queue underwent. So printing such a pid is rather useless and above all is often rather confusing because it reports a random pid between those of the associated processes. This commit addresses this issue by printing SHARED instead of a pid if the queue is shared. Signed-off-by: Francesco Pollicino Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 10 ++++++++++ block/bfq-iosched.h | 23 +++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 500b04df9efa..7d95d9c01036 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2590,6 +2590,16 @@ bfq_merge_bfqqs(struct bfq_data *bfqd, struct bfq_io_cq *bic, * assignment causes no harm). */ new_bfqq->bic = NULL; + /* + * If the queue is shared, the pid is the pid of one of the associated + * processes. Which pid depends on the exact sequence of merge events + * the queue underwent. So printing such a pid is useless and confusing + * because it reports a random pid between those of the associated + * processes. + * We mark such a queue with a pid -1, and then print SHARED instead of + * a pid in logging messages. + */ + new_bfqq->pid = -1; bfqq->bic = NULL; /* release process reference to bfqq */ bfq_put_queue(bfqq); diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 829730b96fb2..6410cc9a064d 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -32,6 +32,8 @@ #define BFQ_DEFAULT_GRP_IOPRIO 0 #define BFQ_DEFAULT_GRP_CLASS IOPRIO_CLASS_BE +#define MAX_PID_STR_LENGTH 12 + /* * Soft real-time applications are extremely more latency sensitive * than interactive ones. Over-raise the weight of the former to @@ -1016,13 +1018,23 @@ void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq); /* --------------- end of interface of B-WF2Q+ ---------------- */ /* Logging facilities. */ +static void bfq_pid_to_str(int pid, char *str, int len) +{ + if (pid != -1) + snprintf(str, len, "%d", pid); + else + snprintf(str, len, "SHARED-"); +} + #ifdef CONFIG_BFQ_GROUP_IOSCHED struct bfq_group *bfqq_group(struct bfq_queue *bfqq); #define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do { \ + char pid_str[MAX_PID_STR_LENGTH]; \ + bfq_pid_to_str((bfqq)->pid, pid_str, MAX_PID_STR_LENGTH); \ blk_add_cgroup_trace_msg((bfqd)->queue, \ bfqg_to_blkg(bfqq_group(bfqq))->blkcg, \ - "bfq%d%c " fmt, (bfqq)->pid, \ + "bfq%s%c " fmt, pid_str, \ bfq_bfqq_sync((bfqq)) ? 'S' : 'A', ##args); \ } while (0) @@ -1033,10 +1045,13 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq); #else /* CONFIG_BFQ_GROUP_IOSCHED */ -#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) \ - blk_add_trace_msg((bfqd)->queue, "bfq%d%c " fmt, (bfqq)->pid, \ +#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do { \ + char pid_str[MAX_PID_STR_LENGTH]; \ + bfq_pid_to_str((bfqq)->pid, pid_str, MAX_PID_STR_LENGTH); \ + blk_add_trace_msg((bfqd)->queue, "bfq%s%c " fmt, pid_str, \ bfq_bfqq_sync((bfqq)) ? 'S' : 'A', \ - ##args) + ##args) \ +} while (0) #define bfq_log_bfqg(bfqd, bfqg, fmt, args...) do {} while (0) #endif /* CONFIG_BFQ_GROUP_IOSCHED */ -- 2.20.1