From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Jeff Moyer <jmoyer@redhat.com>,
Jens Axboe <jens.axboe@oracle.com>,
Suresh Jayaraman <sjayaraman@suse.de>
Subject: [088/107] cfq: break apart merged cfqqs if they stop cooperating
Date: Wed, 02 Nov 2011 15:14:54 -0700 [thread overview]
Message-ID: <20111102221458.197767137@clark.kroah.org> (raw)
In-Reply-To: <20111102221600.GA26650@kroah.com>
2.6.32-longterm review patch. If anyone has any objections, please let us know.
------------------
From: Jeff Moyer <jmoyer@redhat.com>
commit e6c5bc737ab71e4af6025ef7d150f5a26ae5f146 upstream.
cfq_queues are merged if they are issuing requests within the mean seek
distance of one another. This patch detects when the coopearting stops and
breaks the queues back up.
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
block/cfq-iosched.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 76 insertions(+), 3 deletions(-)
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -38,6 +38,12 @@ static int cfq_slice_idle = HZ / 125;
*/
#define CFQ_MIN_TT (2)
+/*
+ * Allow merged cfqqs to perform this amount of seeky I/O before
+ * deciding to break the queues up again.
+ */
+#define CFQQ_COOP_TOUT (HZ)
+
#define CFQ_SLICE_SCALE (5)
#define CFQ_HW_QUEUE_MIN (5)
@@ -116,6 +122,7 @@ struct cfq_queue {
u64 seek_total;
sector_t seek_mean;
sector_t last_request_pos;
+ unsigned long seeky_start;
pid_t pid;
@@ -1041,6 +1048,11 @@ static struct cfq_queue *cfq_close_coope
{
struct cfq_queue *cfqq;
+ if (!cfq_cfqq_sync(cur_cfqq))
+ return NULL;
+ if (CFQQ_SEEKY(cur_cfqq))
+ return NULL;
+
/*
* We should notice if some of the queues are cooperating, eg
* working closely on the same area of the disk. In that case,
@@ -1055,6 +1067,8 @@ static struct cfq_queue *cfq_close_coope
*/
if (!cfq_cfqq_sync(cfqq))
return NULL;
+ if (CFQQ_SEEKY(cfqq))
+ return NULL;
return cfqq;
}
@@ -1186,7 +1200,7 @@ static int cfqq_process_refs(struct cfq_
static void cfq_setup_merge(struct cfq_queue *cfqq, struct cfq_queue *new_cfqq)
{
- int process_refs;
+ int process_refs, new_process_refs;
struct cfq_queue *__cfqq;
/* Avoid a circular list and skip interim queue merges */
@@ -1204,8 +1218,17 @@ static void cfq_setup_merge(struct cfq_q
if (process_refs == 0)
return;
- cfqq->new_cfqq = new_cfqq;
- atomic_add(process_refs, &new_cfqq->ref);
+ /*
+ * Merge in the direction of the lesser amount of work.
+ */
+ new_process_refs = cfqq_process_refs(new_cfqq);
+ if (new_process_refs >= process_refs) {
+ cfqq->new_cfqq = new_cfqq;
+ atomic_add(process_refs, &new_cfqq->ref);
+ } else {
+ new_cfqq->new_cfqq = cfqq;
+ atomic_add(new_process_refs, &cfqq->ref);
+ }
}
/*
@@ -2040,6 +2063,19 @@ cfq_update_io_seektime(struct cfq_data *
total = cfqq->seek_total + (cfqq->seek_samples/2);
do_div(total, cfqq->seek_samples);
cfqq->seek_mean = (sector_t)total;
+
+ /*
+ * If this cfqq is shared between multiple processes, check to
+ * make sure that those processes are still issuing I/Os within
+ * the mean seek distance. If not, it may be time to break the
+ * queues apart again.
+ */
+ if (cfq_cfqq_coop(cfqq)) {
+ if (CFQQ_SEEKY(cfqq) && !cfqq->seeky_start)
+ cfqq->seeky_start = jiffies;
+ else if (!CFQQ_SEEKY(cfqq))
+ cfqq->seeky_start = 0;
+ }
}
/*
@@ -2410,6 +2446,32 @@ cfq_merge_cfqqs(struct cfq_data *cfqd, s
return cic_to_cfqq(cic, 1);
}
+static int should_split_cfqq(struct cfq_queue *cfqq)
+{
+ if (cfqq->seeky_start &&
+ time_after(jiffies, cfqq->seeky_start + CFQQ_COOP_TOUT))
+ return 1;
+ return 0;
+}
+
+/*
+ * Returns NULL if a new cfqq should be allocated, or the old cfqq if this
+ * was the last process referring to said cfqq.
+ */
+static struct cfq_queue *
+split_cfqq(struct cfq_io_context *cic, struct cfq_queue *cfqq)
+{
+ if (cfqq_process_refs(cfqq) == 1) {
+ cfqq->seeky_start = 0;
+ cfqq->pid = current->pid;
+ cfq_clear_cfqq_coop(cfqq);
+ return cfqq;
+ }
+
+ cic_set_cfqq(cic, NULL, 1);
+ cfq_put_queue(cfqq);
+ return NULL;
+}
/*
* Allocate cfq data structures associated with this request.
*/
@@ -2432,12 +2494,23 @@ cfq_set_request(struct request_queue *q,
if (!cic)
goto queue_fail;
+new_queue:
cfqq = cic_to_cfqq(cic, is_sync);
if (!cfqq || cfqq == &cfqd->oom_cfqq) {
cfqq = cfq_get_queue(cfqd, is_sync, cic->ioc, gfp_mask);
cic_set_cfqq(cic, cfqq, is_sync);
} else {
/*
+ * If the queue was seeky for too long, break it apart.
+ */
+ if (cfq_cfqq_coop(cfqq) && should_split_cfqq(cfqq)) {
+ cfq_log_cfqq(cfqd, cfqq, "breaking apart cfqq");
+ cfqq = split_cfqq(cic, cfqq);
+ if (!cfqq)
+ goto new_queue;
+ }
+
+ /*
* Check to see if this queue is scheduled to merge with
* another, closely cooperating queue. The merging of
* queues happens here as it must be done in process context.
next prev parent reply other threads:[~2011-11-03 2:08 UTC|newest]
Thread overview: 122+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-02 22:16 [000/107] 2.6.32.47-longterm review Greg KH
2011-11-02 22:13 ` [001/107] USB: ftdi_sio: add Calao reference board support Greg KH
2011-11-02 22:13 ` [002/107] USB: EHCI: Do not rely on PORT_SUSPEND to stop USB resuming in ehci_bus_resume() Greg KH
2011-11-02 22:13 ` [003/107] rt2x00: do not drop usb dev reference counter on suspend Greg KH
2011-11-02 22:13 ` [004/107] atm: br2684: Fix oops due to skb->dev being NULL Greg KH
2011-11-02 22:13 ` [005/107] sparc: Allow handling signals when stack is corrupted Greg KH
2011-11-04 4:33 ` Ben Hutchings
2011-11-04 6:09 ` David Miller
2011-11-02 22:13 ` [006/107] sparc: fix array bounds error setting up PCIC NMI trap Greg KH
2011-11-02 22:13 ` [007/107] Fix broken backport for IPv6 tunnels Greg KH
2011-11-02 22:13 ` [008/107] net: Fix IPv6 GSO type checks in Intel ethernet drivers Greg KH
2011-11-02 22:13 ` [009/107] ipv6: Add GSO support on forwarding path Greg KH
2011-11-02 22:13 ` [010/107] Revert "x86, hotplug: Use mwait to offline a processor, fix the legacy case" Greg KH
2011-11-02 22:13 ` [011/107] GRO: fix merging a paged skb after non-paged skbs Greg KH
2011-11-02 22:13 ` [012/107] xen-blkfront: fix data size for xenbus_gather in blkfront_connect Greg KH
2011-11-02 22:13 ` [013/107] md/linear: avoid corrupting structure while waiting for rcu_free to complete Greg KH
2011-11-02 22:13 ` [014/107] powerpc/mpic: Fix problem that affinity is not updated Greg KH
2011-11-02 22:13 ` [015/107] powerpc/pci: Check devices status property when scanning OF tree Greg KH
2011-11-02 22:13 ` [016/107] xen: x86_32: do not enable iterrupts when returning from exception in interrupt context Greg KH
2011-11-02 22:13 ` [017/107] xen/smp: Warn user why they keel over - nosmp or noapic and what to use instead Greg KH
2011-11-02 22:13 ` [018/107] ARM: davinci: da850 EVM: read mac address from SPI flash Greg KH
2011-11-02 22:13 ` [019/107] md: Fix handling for devices from 2TB to 4TB in 0.90 metadata Greg KH
2011-11-02 22:13 ` [020/107] net/9p: fix client code to fail more gracefully on protocol error Greg KH
2011-11-02 22:13 ` [021/107] fs/9p: Fid is not valid after a failed clunk Greg KH
2011-11-02 22:13 ` [022/107] net/9p: Fix the msize calculation Greg KH
2011-11-02 22:13 ` [023/107] irda: fix smsc-ircc2 section mismatch warning Greg KH
2011-11-02 22:13 ` [024/107] [SCSI] qla2xxx: Correct inadvertent loop state transitions during port-update handling Greg KH
2011-11-02 22:13 ` [025/107] e1000: Fix driver to be used on PA RISC C8000 workstations Greg KH
2011-11-02 22:13 ` [026/107] ASoC: Fix reporting of partial jack updates Greg KH
2011-11-02 22:13 ` [027/107] ALSA: HDA: Cirrus - fix "Surround Speaker" volume control name Greg KH
2011-11-02 22:13 ` [028/107] drm/radeon/kms: fix typo in r100_blit_copy Greg KH
2011-11-03 13:01 ` Deucher, Alexander
2011-11-03 13:15 ` Greg KH
2011-11-02 22:13 ` [029/107] cifs: fix possible memory corruption in CIFSFindNext Greg KH
2011-11-02 22:13 ` [030/107] b43: Fix beacon problem in ad-hoc mode Greg KH
2011-11-02 22:13 ` [031/107] wireless: Reset beacon_found while updating regulatory Greg KH
2011-11-02 22:13 ` [032/107] USB: PL2303: correctly handle baudrates above 115200 Greg KH
2011-11-02 22:13 ` [033/107] ASIX: Add AX88772B USB ID Greg KH
2011-11-02 22:14 ` [034/107] hvc_console: Improve tty/console put_chars handling Greg KH
2011-11-02 22:14 ` [035/107] TPM: Call tpm_transmit with correct size Greg KH
2011-11-02 22:14 ` [036/107] TPM: Zero buffer after copying to userspace Greg KH
2011-11-02 22:14 ` [037/107] [SCSI] libiscsi_tcp: fix LLD data allocation Greg KH
2011-11-02 22:14 ` [038/107] cnic: Improve NETDEV_UP event handling Greg KH
2011-11-02 22:14 ` [039/107] ALSA: hda/realtek - Avoid bogus HP-pin assignment Greg KH
2011-11-02 22:14 ` [040/107] [SCSI] 3w-9xxx: fix iommu_iova leak Greg KH
2011-11-02 22:14 ` [041/107] [SCSI] aacraid: reset should disable MSI interrupt Greg KH
2011-11-02 22:14 ` [042/107] [SCSI] libsas: fix failure to revalidate domain for anything but the first expander child Greg KH
2011-11-02 22:14 ` [043/107] cfg80211: Fix validation of AKM suites Greg KH
2011-11-02 22:14 ` [044/107] splice: direct_splice_actor() should not use pos in sd Greg KH
2011-11-02 22:14 ` [045/107] [SCSI] libsas: fix panic when single phy is disabled on a wide port Greg KH
2011-11-02 22:14 ` [046/107] ahci: Enable SB600 64bit DMA on Asus M3A Greg KH
2011-11-02 22:14 ` [047/107] HID: usbhid: Add support for SiGma Micro chip Greg KH
2011-11-02 22:14 ` [048/107] hwmon: (w83627ehf) Properly report thermal diode sensors Greg KH
2011-11-02 22:14 ` [049/107] x25: Prevent skb overreads when checking call user data Greg KH
2011-11-02 22:14 ` [050/107] block: check for proper length of iov entries earlier in blk_rq_map_user_iov() Greg KH
2011-11-04 15:24 ` Ben Hutchings
2011-11-04 17:14 ` Greg KH
2011-11-04 19:06 ` Ben Hutchings
2011-11-04 20:28 ` Greg KH
2011-11-04 21:00 ` Dan Carpenter
2011-11-04 21:04 ` Greg KH
2011-11-04 19:36 ` Dan Carpenter
2011-11-02 22:14 ` [051/107] staging: quatech_usb2: Potential lost wakeup scenario in TIOCMIWAIT Greg KH
2011-11-02 22:14 ` [052/107] USB: qcserial: add device ID for "HP un2430 Mobile Broadband Module" Greg KH
2011-11-02 22:14 ` [053/107] xhci-mem.c: Check for ring->first_seg != NULL Greg KH
2011-11-02 22:14 ` [054/107] [SCSI] ipr: Always initiate hard reset in kdump kernel Greg KH
2011-11-02 22:14 ` [055/107] [SCSI] libsas: set sas_address and device type of rphy Greg KH
2011-11-02 22:14 ` [056/107] ALSA: HDA: Add new revision for ALC662 Greg KH
2011-11-02 22:14 ` [057/107] x86: Fix compilation bug in kprobes twobyte_is_boostable Greg KH
2011-11-02 22:14 ` [058/107] epoll: fix spurious lockdep warnings Greg KH
2011-11-02 22:14 ` [059/107] usbmon vs. tcpdump: fix dropped packet count Greg KH
2011-11-02 22:14 ` [060/107] USB: storage: Use normalized sense when emulating autosense Greg KH
2011-11-02 22:14 ` [061/107] USB: pid_ns: ensure pid is not freed during kill_pid_info_as_uid Greg KH
2011-11-02 22:14 ` [062/107] usb: cdc-acm: Owen SI-30 support Greg KH
2011-11-02 22:14 ` [063/107] USB: add RESET_RESUME for webcams shown to be quirky Greg KH
2011-11-02 22:14 ` [064/107] USB: pl2303: add id for SMART device Greg KH
2011-11-02 22:14 ` [065/107] USB: ftdi_sio: add PID for Sony Ericsson Urban Greg KH
2011-11-02 22:14 ` [066/107] USB: ftdi_sio: Support TI/Luminary Micro Stellaris BD-ICDI Board Greg KH
2011-11-02 22:14 ` [067/107] QE/FHCI: fixed the CONTROL bug Greg KH
2011-11-02 22:14 ` [068/107] Update email address for stable patch submission Greg KH
2011-11-03 8:08 ` Christoph Biedl
2011-11-03 8:25 ` Sven Joachim
2011-11-03 12:18 ` Greg KH
2011-11-02 22:14 ` [069/107] kobj_uevent: Ignore if some listeners cannot handle message Greg KH
2011-11-02 22:14 ` [070/107] kmod: prevent kmod_loop_msg overflow in __request_module() Greg KH
2011-11-02 22:14 ` [071/107] time: Change jiffies_to_clock_t() argument type to unsigned long Greg KH
2011-11-02 22:14 ` [072/107] nfsd4: Remove check for a 32-bit cookie in nfsd4_readdir() Greg KH
2011-11-02 22:14 ` [073/107] nfsd4: ignore WANT bits in open downgrade Greg KH
2011-11-02 22:14 ` [074/107] ASoC: wm8940: Properly set codec->dapm.bias_level Greg KH
2011-11-02 22:14 ` [075/107] ASoC: ak4642: fixup cache register table Greg KH
2011-11-02 22:14 ` [076/107] ASoC: ak4535: " Greg KH
2011-11-02 22:14 ` [077/107] KVM: s390: check cpu_id prior to using it Greg KH
2011-11-02 22:14 ` [078/107] [S390] ccwgroup: move attributes to attribute group Greg KH
2011-11-02 22:14 ` [079/107] iommu/amd: Fix wrong shift direction Greg KH
2011-11-02 22:14 ` [080/107] carminefb: Fix module parameters permissions Greg KH
2011-11-02 22:14 ` [081/107] [media] uvcvideo: Set alternate setting 0 on resume if the bus has been reset Greg KH
2011-11-02 22:14 ` [082/107] [media] tuner_xc2028: Allow selection of the frequency adjustment code for XC3028 Greg KH
2011-11-02 22:14 ` [083/107] plat-mxc: iomux-v3.h: implicitly enable pull-up/down when thats desired Greg KH
2011-11-02 22:14 ` [084/107] um: fix ubd cow size Greg KH
2011-11-02 22:14 ` [085/107] cfq: calculate the seek_mean per cfq_queue not per cfq_io_context Greg KH
2011-11-02 22:14 ` [086/107] cfq: merge cooperating cfq_queues Greg KH
2011-11-02 22:14 ` [087/107] cfq: change the meaning of the cfqq_coop flag Greg KH
2011-11-02 22:14 ` Greg KH [this message]
2011-11-02 22:14 ` [089/107] cfq-iosched: get rid of the coop_preempt flag Greg KH
2011-11-02 22:14 ` [090/107] cfq: Dont allow queue merges for queues that have no process references Greg KH
2011-11-02 22:14 ` [091/107] xen/timer: Missing IRQF_NO_SUSPEND in timer code broke suspend Greg KH
2011-11-02 22:14 ` [092/107] KVM: x86: Reset tsc_timestamp on TSC writes Greg KH
2011-11-02 22:14 ` [093/107] genirq: Add IRQF_RESUME_EARLY and resume such IRQs earlier Greg KH
2011-11-02 22:15 ` [094/107] Revert "usb: musb: restore INDEX register in resume path" Greg KH
2011-11-02 22:15 ` [095/107] Revert "MIPS: MTX-1: Make au1000_eth probe all PHY Greg KH
2011-11-02 22:15 ` [096/107] watchdog: mtx1-wdt: fix build failure Greg KH
2011-11-02 22:15 ` [097/107] kcore: fix test for end of list Greg KH
2011-11-02 22:15 ` [098/107] thinkpad-acpi: module autoloading for newer Lenovo ThinkPads Greg KH
2011-11-02 22:15 ` [099/107] scm: lower SCM_MAX_FD Greg KH
2011-11-02 22:15 ` [100/107] deal with races in /proc/*/{syscall,stack,personality} Greg KH
2011-11-02 22:15 ` [101/107] NLM: Dont hang forever on NLM unlock requests Greg KH
2011-11-02 22:15 ` [102/107] Bluetooth: l2cap and rfcomm: fix 1 byte infoleak to userspace Greg KH
2011-11-02 22:15 ` [103/107] vm: fix vm_pgoff wrap in stack expansion Greg KH
2011-11-02 22:15 ` [104/107] vm: fix vm_pgoff wrap in upward expansion Greg KH
2011-11-02 22:15 ` [105/107] Bluetooth: Prevent buffer overflow in l2cap config request Greg KH
2011-11-02 22:15 ` [106/107] nl80211: fix overflow in ssid_len Greg KH
2011-11-02 22:15 ` [107/107] net_sched: Fix qdisc_notify() Greg KH
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=20111102221458.197767137@clark.kroah.org \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=jens.axboe@oracle.com \
--cc=jmoyer@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sjayaraman@suse.de \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®