From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Jeff Moyer <jmoyer@redhat.com>,
Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>,
Jens Axboe <axboe@fb.com>
Subject: [PATCH 3.10 30/53] cfq-iosched: fix incorrect filing of rt async cfqq
Date: Tue, 3 Mar 2015 22:06:33 -0800 [thread overview]
Message-ID: <20150304054615.021452481@linuxfoundation.org> (raw)
In-Reply-To: <20150304054609.869052846@linuxfoundation.org>
3.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Moyer <jmoyer@redhat.com>
commit c6ce194325cef342313e3d27620411ce90a89c50 upstream.
Hi,
If you can manage to submit an async write as the first async I/O from
the context of a process with realtime scheduling priority, then a
cfq_queue is allocated, but filed into the wrong async_cfqq bucket. It
ends up in the best effort array, but actually has realtime I/O
scheduling priority set in cfqq->ioprio.
The reason is that cfq_get_queue assumes the default scheduling class and
priority when there is no information present (i.e. when the async cfqq
is created):
static struct cfq_queue *
cfq_get_queue(struct cfq_data *cfqd, bool is_sync, struct cfq_io_cq *cic,
struct bio *bio, gfp_t gfp_mask)
{
const int ioprio_class = IOPRIO_PRIO_CLASS(cic->ioprio);
const int ioprio = IOPRIO_PRIO_DATA(cic->ioprio);
cic->ioprio starts out as 0, which is "invalid". So, class of 0
(IOPRIO_CLASS_NONE) is passed to cfq_async_queue_prio like so:
async_cfqq = cfq_async_queue_prio(cfqd, ioprio_class, ioprio);
static struct cfq_queue **
cfq_async_queue_prio(struct cfq_data *cfqd, int ioprio_class, int ioprio)
{
switch (ioprio_class) {
case IOPRIO_CLASS_RT:
return &cfqd->async_cfqq[0][ioprio];
case IOPRIO_CLASS_NONE:
ioprio = IOPRIO_NORM;
/* fall through */
case IOPRIO_CLASS_BE:
return &cfqd->async_cfqq[1][ioprio];
case IOPRIO_CLASS_IDLE:
return &cfqd->async_idle_cfqq;
default:
BUG();
}
}
Here, instead of returning a class mapped from the process' scheduling
priority, we get back the bucket associated with IOPRIO_CLASS_BE.
Now, there is no queue allocated there yet, so we create it:
cfqq = cfq_find_alloc_queue(cfqd, is_sync, cic, bio, gfp_mask);
That function ends up doing this:
cfq_init_cfqq(cfqd, cfqq, current->pid, is_sync);
cfq_init_prio_data(cfqq, cic);
cfq_init_cfqq marks the priority as having changed. Then, cfq_init_prio
data does this:
ioprio_class = IOPRIO_PRIO_CLASS(cic->ioprio);
switch (ioprio_class) {
default:
printk(KERN_ERR "cfq: bad prio %x\n", ioprio_class);
case IOPRIO_CLASS_NONE:
/*
* no prio set, inherit CPU scheduling settings
*/
cfqq->ioprio = task_nice_ioprio(tsk);
cfqq->ioprio_class = task_nice_ioclass(tsk);
break;
So we basically have two code paths that treat IOPRIO_CLASS_NONE
differently, which results in an RT async cfqq filed into a best effort
bucket.
Attached is a patch which fixes the problem. I'm not sure how to make
it cleaner. Suggestions would be welcome.
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Tested-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
block/cfq-iosched.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -3646,12 +3646,17 @@ static struct cfq_queue *
cfq_get_queue(struct cfq_data *cfqd, bool is_sync, struct cfq_io_cq *cic,
struct bio *bio, gfp_t gfp_mask)
{
- const int ioprio_class = IOPRIO_PRIO_CLASS(cic->ioprio);
- const int ioprio = IOPRIO_PRIO_DATA(cic->ioprio);
+ int ioprio_class = IOPRIO_PRIO_CLASS(cic->ioprio);
+ int ioprio = IOPRIO_PRIO_DATA(cic->ioprio);
struct cfq_queue **async_cfqq = NULL;
struct cfq_queue *cfqq = NULL;
if (!is_sync) {
+ if (!ioprio_valid(cic->ioprio)) {
+ struct task_struct *tsk = current;
+ ioprio = task_nice_ioprio(tsk);
+ ioprio_class = task_nice_ioclass(tsk);
+ }
async_cfqq = cfq_async_queue_prio(cfqd, ioprio_class, ioprio);
cfqq = *async_cfqq;
}
next prev parent reply other threads:[~2015-03-04 8:30 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-04 6:06 [PATCH 3.10 00/53] 3.10.71-stable review Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 01/53] Bluetooth: ath3k: workaround the compatibility issue with xHCI controller Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 02/53] xfs: ensure buffer types are set correctly Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 03/53] xfs: inode unlink does not set AGI buffer type Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 04/53] xfs: set superblock buffer type correctly Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 05/53] fsnotify: fix handling of renames in audit Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 06/53] iwlwifi: pcie: disable the SCD_BASE_ADDR when we resume from WoWLAN Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 07/53] iwlwifi: mvm: validate tid and sta_id in ba_notif Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 08/53] iwlwifi: mvm: fix failure path when power_update fails in add_interface Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 09/53] iwlwifi: mvm: always use mac color zero Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 10/53] HID: i2c-hid: Limit reads to wMaxInputLength bytes for input events Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 11/53] PCI: Generate uppercase hex for modalias var in uevent Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 14/53] [media] lmedm04: Fix usb_submit_urb BOGUS urb xfer, pipe 1 != type 3 in interrupt urb Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 15/53] ALSA: off by one bug in snd_riptide_joystick_probe() Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 16/53] ALSA: hdspm - Constrain periods to 2 on older cards Greg Kroah-Hartman
2015-03-04 10:03 ` Adrian Knoth
2015-03-04 18:19 ` Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 17/53] power_supply: 88pm860x: Fix leaked power supply on probe fail Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 18/53] mmc: sdhci-pxav3: fix setting of pdata->clk_delay_cycles Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 19/53] nfs: dont call blocking operations while !TASK_RUNNING Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 20/53] MIPS: KVM: Deliver guest interrupts after local_irq_disable() Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 21/53] tracing: Fix unmapping loop in tracing_mark_write Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 22/53] ARM: 8284/1: sa1100: clear RCSR_SMR on resume Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 23/53] tpm_tis: verify interrupt during init Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 24/53] tpm: Fix NULL return in tpm_ibmvtpm_get_desired_dma Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 25/53] tpm/tpm_i2c_stm_st33: Fix potential bug in tpm_stm_i2c_send Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 26/53] Added Little Endian support to vtpm module Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 27/53] NFSv4.1: Fix a kfree() of uninitialised pointers in decode_cb_sequence_args Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 28/53] iscsi-target: Drop problematic active_ts_list usage Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 29/53] cfq-iosched: handle failure of cfq group allocation Greg Kroah-Hartman
2015-03-04 6:06 ` Greg Kroah-Hartman [this message]
2015-03-04 6:06 ` [PATCH 3.10 31/53] axonram: Fix bug in direct_access Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 32/53] tty: Prevent untrappable signals from malicious program Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 33/53] USB: cp210x: add ID for RUGGEDCOM USB Serial Console Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 34/53] USB: fix use-after-free bug in usb_hcd_unlink_urb() Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 35/53] usb: core: buffer: smallest buffer should start at ARCH_DMA_MINALIGN Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 36/53] vt: provide notifications on selection changes Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 37/53] ARM: pxa: add regulator_has_full_constraints to corgi board file Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 38/53] ARM: pxa: add regulator_has_full_constraints to poodle " Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 39/53] kdb: fix incorrect counts in KDB summary command output Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 40/53] ntp: Fixup adjtimex freq validation on 32-bit systems Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 41/53] ARC: fix page address calculation if PAGE_OFFSET != LINUX_LINK_BASE Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 42/53] KVM: s390: floating irqs: fix user triggerable endless loop Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 43/53] KVM: MIPS: Dont leak FPU/DSP to guest Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 44/53] KVM: x86: update masterclock values on TSC writes Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 45/53] hx4700: regulator: declare full constraints Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 46/53] arm64: compat Fix siginfo_t -> compat_siginfo_t conversion on big endian Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 47/53] gpio: tps65912: fix wrong container_of arguments Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 48/53] metag: Fix KSTK_EIP() and KSTK_ESP() macros Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 49/53] md/raid5: Fix livelock when array is both resyncing and degraded Greg Kroah-Hartman
2015-03-04 14:09 ` Jes Sorensen
2015-03-04 6:06 ` [PATCH 3.10 51/53] jffs2: fix handling of corrupted summary length Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 52/53] blk-throttle: check stats_cpu before reading it from sysfs Greg Kroah-Hartman
2015-03-04 6:06 ` [PATCH 3.10 53/53] x86, mm/ASLR: Fix stack randomization on 64-bit systems Greg Kroah-Hartman
2015-03-04 14:08 ` [PATCH 3.10 00/53] 3.10.71-stable review Guenter Roeck
2015-03-04 14:20 ` Luis Henriques
2015-03-04 18:16 ` Greg Kroah-Hartman
2015-03-04 23:40 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150304054615.021452481@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=axboe@fb.com \
--cc=hidehiro.kawai.ez@hitachi.com \
--cc=jmoyer@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome