From patchwork Thu Mar 7 16:25:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 159887 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7628777jad; Thu, 7 Mar 2019 08:26:45 -0800 (PST) X-Google-Smtp-Source: APXvYqx3PIh8A26ZkyBsC6JIptkTVBnzJiLHkdeh0E2/CFqzEjqHUIjvZ/RzUWvzzjSWk5W+zDgM X-Received: by 2002:a17:902:822:: with SMTP id 31mr13705785plk.290.1551976004986; Thu, 07 Mar 2019 08:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551976004; cv=none; d=google.com; s=arc-20160816; b=FUlc61cGh9YAtBqoE886Lq17/xwMtfoMODS/5zwfJRQ4D7I947saa/WqnWk1eqW84n wuoj+6BRduR73rZU4OyDMPU+TsQOnJnr6LeOwB8ZLqq/9iaNVhs210wO+w4qE+CyTgJD RJrxIknZU6dYlyuxyolWgtT2ckXeBuLnH9t5Zq7hM8d0RnAqTT1MuTQ9lcBJOUtOc7dt su41OfuvmYj7SoZio8CeTc+K9z3lLJ/jqM43Qt0TbHv2WgLykbf/HWvL6NGsroK355pk yqAbdR7YbGG2Xca3m+ZuVykDdT7l0sAl1l/T9aCsul/QTMqy3yuGUoyV1eaJOHisTOd8 Vecg== 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=xlQD5/IUhsVAwG7WZ+Uc2ij3RLscMuoaMIxAkg1O+iU=; b=kUYf1gsTE+CdLtBBbawErBkFI9m84QXM01F2tmH9KOh1M647or7GsivFacFu676/8H pis1JDH/pfZlYdzaDJWVekkBFbgG0T/P+ZmxcEzppAVqAl2gl/N8Rh8Z0PabvB4zRGrf 3X2xd6PCD4Hl6SoRJFHBl0bajOO7Aww8r0WBfKyLe+DFiSBT+jY/HVwg8c1Y2hW+hrbq P/OjYnekps8ltX7Lk+5uSIDwnFtsUGcfnl9/SvQ7AT1cS4gy280IF1hdVyozEGySYA/d uMhzL8Gn3B+gjhd3bRswa4sflVP2/MDfYlTFu7f5Gw6GjPyAUM+VDJ8hDYha1NVHxSXd zGOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q1E4T6UH; 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 l62si4059977pge.109.2019.03.07.08.26.44; Thu, 07 Mar 2019 08:26:44 -0800 (PST) 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=Q1E4T6UH; 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 S1726596AbfCGQ0i (ORCPT + 31 others); Thu, 7 Mar 2019 11:26:38 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:47038 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726450AbfCGQ0W (ORCPT ); Thu, 7 Mar 2019 11:26:22 -0500 Received: by mail-wr1-f67.google.com with SMTP id i16so18132947wrs.13 for ; Thu, 07 Mar 2019 08:26:21 -0800 (PST) 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=xlQD5/IUhsVAwG7WZ+Uc2ij3RLscMuoaMIxAkg1O+iU=; b=Q1E4T6UHR4NyVlm1gbaXS3LV4WXKIF/F0NLzALIOjQ/JI8bU/ftJotOWy8XUY8UJ0j d1e7gj4cZHb4l21rHhfjQFcTvhG+OuqT9BIhi6ORBNZ/PP3NLmZYw1FXyv5HJk4Sbyrl Hjsa4b56ODAD1QEAuleKB/+IOgGMLiEFEhVhLeRy68WCrq5MsTbojThwSnDC++kO7HI6 YBQ6TAyLL+O4BHgIDct2NxkS96no/ITQ31rBbcoPwKjomcMgLlWY4mDnENBoBcRiFPca 8a3tTQ4omdGB+GToHNIlWVfuyaMS9bmCYT/V+tS6eKNPwYlvXR5+PY3ypSoEyCzul+ui WQWQ== 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=xlQD5/IUhsVAwG7WZ+Uc2ij3RLscMuoaMIxAkg1O+iU=; b=Fi2FM8m45S16itL/c6DkFfPCvNRY1M60GQBiOm7YnjfiR47b7DR0VrtSsFTODi7FXV 4VNR6YNCBa7gpfxAfxUmuNBdpoZz0exuatCPh2DukaXMeGb1CgghY8GAKycRltWUARMi bzBP5Acu4KBsPcJyBWHtvMEcufh08kTfeFG77DH76MtLqJ20dKuoInnEwEpi+pTduQ6a Ij/t5YOCHguXyVNbDhKBP+W9iL6yfR0UC18NL+ECCJfWR+oNggD55BMatqW4sqdI1vo2 Qu1ZmdZyYQeDfyuhS/r+KJ2CHKSJBHAFiVimFYkpkZTWu3AAwhY98GkPX8kLqheEyojk DYmg== X-Gm-Message-State: APjAAAXjnF7i4hDVTL/ybYzsGb0R3X/bCFIY2ilEtot/NyHCk8QvMpZJ f4IDj8wmxY0zA4WLIS6q7J7bFw== X-Received: by 2002:a5d:4e50:: with SMTP id r16mr7028459wrt.8.1551975980402; Thu, 07 Mar 2019 08:26:20 -0800 (PST) Received: from localhost.localdomain (146-241-117-61.dyn.eolo.it. [146.241.117.61]) by smtp.gmail.com with ESMTPSA id o127sm5801797wmo.20.2019.03.07.08.26.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 08:26:19 -0800 (PST) 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, Paolo Valente Subject: [PATCH BUGFIX IMPROVEMENT 7/8] block, bfq: print SHARED instead of pid for shared queues in logs Date: Thu, 7 Mar 2019 17:25:53 +0100 Message-Id: <20190307162554.77205-8-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190307162554.77205-1-paolo.valente@linaro.org> References: <20190307162554.77205-1-paolo.valente@linaro.org> MIME-Version: 1.0 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 | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) -- 2.20.1 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..21ddb19cc322 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. */ +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) @@ -1034,7 +1046,9 @@ 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, \ + 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) #define bfq_log_bfqg(bfqd, bfqg, fmt, args...) do {} while (0)