Skip to contentSkip to conversation

checkpatch: length of git commit IDs

DISCUSSION Stefan Richter 2 participants 7 messages Feb 1, 2015 – Feb 2, 2015 SCSI

lore
Share & tools
lore
#0 lore raw

Hi Joe,

I was just told that 12 is less than 12:

Quoted 8 lines

ERROR: Please use 12 or more chars for the git commit ID like: 'Commit 01234567890ab ("commit description")' #5:
Commit 2a48fc0ab242 "block: autoconvert trivial BKL users to private

total: 1 errors, 0 warnings, 66 lines checked

patches/scsi-sr-fix-multi-drive-performance-remove-bkl-replacement.patch has style problems, please review.

Signature · 3 lines
Stefan Richter
-=====-===== --=- ----=
http://arcgraph.de/sr/
#1 lore raw
Quoted 1 line · Stefan Richter

Hi Joe,

Hi Stefan.

Quoted 5 lines

I was just told that 12 is less than 12:

Quoted 3 lines

ERROR: Please use 12 or more chars for the git commit ID like: 'Commit 01234567890ab ("commit description")' #5:
Commit 2a48fc0ab242 "block: autoconvert trivial BKL users to private

Yeah, that message isn't very descriptive.

It really wants parentheses around the commit
message like:

Commit 2a48fc0ab242 ("block: autoconvert trivial BKL users to private

Try the version in -next. I think it has a
better message description.

#2 lore raw
Quoted 9 lines · On Feb 01 Joe Perches wrote:
Quoted 5 lines · Stefan Richter

I was just told that 12 is less than 12:

Quoted 3 lines

ERROR: Please use 12 or more chars for the git commit ID like: 'Commit 01234567890ab ("commit description")' #5:
Commit 2a48fc0ab242 "block: autoconvert trivial BKL users to private

Yeah, that message isn't very descriptive.

Quoted 7 lines

It really wants parentheses around the commit
message like:

Commit 2a48fc0ab242 ("block: autoconvert trivial BKL users to private

Try the version in -next. I think it has a
better message description.

Thanks for the tip; this works for me. (checkpatch.pl from current -next does actually not complain about the line without parentheses.)

Signature · 3 lines
Stefan Richter
-=====-===== --=- ----=
http://arcgraph.de/sr/
#3 lore raw
Quoted 13 lines · Stefan Richter
Quoted 12 lines · On Feb 01 Joe Perches wrote:
Quoted 5 lines · Stefan Richter

I was just told that 12 is less than 12:

Quoted 3 lines

ERROR: Please use 12 or more chars for the git commit ID like: 'Commit 01234567890ab ("commit description")' #5:
Commit 2a48fc0ab242 "block: autoconvert trivial BKL users to private

Yeah, that message isn't very descriptive.

It really wants parentheses around the commit
message like:

Quoted 7 lines
Quoted 4 lines

Commit 2a48fc0ab242 ("block: autoconvert trivial BKL users to private

Try the version in -next. I think it has a
better message description.

Thanks for the tip; this works for me. (checkpatch.pl from current -next does actually not complain about the line without parentheses.)

Hmm, I think that should be a defect.

Can you send me your git format-patch output please?

#4 lore raw
Quoted 6 lines · On Feb 01 Joe Perches wrote:
Quoted 5 lines · Stefan Richter
Quoted 4 lines · On Feb 01 Joe Perches wrote:
Quoted 3 lines · Stefan Richter
Quoted 3 lines

ERROR: Please use 12 or more chars for the git commit ID like: 'Commit 01234567890ab ("commit description")' #5:
Commit 2a48fc0ab242 "block: autoconvert trivial BKL users to private

[...]

Quoted 6 lines
Quoted 2 lines

Thanks for the tip; this works for me. (checkpatch.pl from current -next does actually not complain about the line without parentheses.)

Hmm, I think that should be a defect.

Can you send me your git format-patch output please?

First of all to be sure: The checkpatch.pl which I last referred to is 158501 bytes in size, and the md5sum is bf953e10cbd7405bcf3e885b24c832bd.

$ scripts/checkpatch.pl patches/scsi-sr-fix-multi-drive-performance-remove-bkl-replacement.patch 
total: 0 errors, 0 warnings, 71 lines checked

patches/scsi-sr-fix-multi-drive-performance-remove-bkl-replacement.patch has no obvious style problems and is ready for submission.

Here is the patch file:

Date: Tue, 28 Feb 2012 15:32:44 +0100
From: Stefan Richter <[email protected]>
Subject: [SCSI] sr: fix multi-drive performance, remove BKL replacement

Commit 2a48fc0ab242 "block: autoconvert trivial BKL users to private mutex" and other commits at the time mechanically swapped BKL for per-driver global mutexes. If the sr driver is any indication, these replacements have still not been checked by anybody for their necessessity, removed where possible, or the sections they serialize reduced to a necessary minimum.

The sr_mutex in particular very noticably degraded performance of CD-DA ripping with multiple drives in parallel. When several instances of "grip" are used with two or more drives, their GUIs became laggier, as did the KDE file manager GUI, and drive utilization was reduced. (During ripping, drive lights flicker instead of staying on most of the time.) IOW time to rip a stack of CDs was increased. I didn't measure this but it is highly noticeable.

On the other hand, I don't see what state sr_mutex would protect. So I removed it entirely and that works fine for me.

Tested with up to six CD-ROM drives connected at the same time (1x IDE, 5x FireWire), 12 grip instances running (2 per drive, one for ripping and the other just polling the TOC as a test), and of course udisks-daemon sitting in the background and polling the CD-ROM drives as usual. GUI lags are reduced and ripping throughput increased to a level how I remember it from BKL era.

Also tested: Erasing and writing a CD-RW with K3B/cdrecord while grip and udisks-daemon poll the CD-RW drive and other grip instances rip CD-DA from three other CD-ROM drives.

========

Quoted 10 lines · Arnd Bergmann

I took another look and I believe the cdi->use_count in cdrom_open/cdrom_release still requires some protection that is currently provided by sr_mutex. Some parts of cdrom_ioctl also access this variable and things like cdi->options or cdi->keeplocked.

I could imagine that you can get rid of the mutex if you turn those into atomics and bitops, but there may be other parts of cdrom_device_info that need locking. A safer option to solve the performance problems could be to replace sr_mutex with a per-device mutex inside of cdrom_device_info.

========

Quoted 19 lines · Otto Meta
Quoted 5 lines · Otto Meta

The single mutex for the sr module, introduced as a BKL replacement, globally serialises all sr ioctls, which hurts multi-drive performance.

This patch replaces sr_mutex with per-device mutexes in struct scsi_cd, allowing concurrent ioctls on different sr devices.

Unfortunately it wasn't as easy as that. The patch seems to introduce a race condition that corrupts a drive's state under certain circumstances.

When two drives (e.g. sr0 and sr1) are attached to the same IDE cable, one drive has its door locked, which will usually be the case after any operation on the drive with inserted media (and whenever it feels like it, even with dev.cdrom.lock=0), and the other drive is unlocked, then executing

  $ eject sr0 & eject sr1

will eject the unlocked drive and the locked drive will return

Quoted 8 lines

eject: unable to eject, last error: Inappropriate ioctl for device

Other drivers down the road probably don't expect concurrent ioctls, so this patch cannot be applied safely at this time. Sorry about the noise.

For the record: Tested with kernels 3.2.35 and 3.8.0-rc1, using IDE CD/DVD drives connected via the drivers ata_piix and pata_pdc202xx_old.

========

---
 drivers/scsi/sr.c |   24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)
drivers/scsi/sr.c +6 -18
@@ -76,7 +76,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM);
 	 CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \
 	 CDC_MRW|CDC_MRW_W|CDC_RAM)
 
-static DEFINE_MUTEX(sr_mutex);
 static int sr_probe(struct device *);
 static int sr_remove(struct device *);
 static int sr_init_command(struct scsi_cmnd *SCpnt);
@@ -516,27 +515,23 @@ static int sr_init_command(struct scsi_c
 
 static int sr_block_open(struct block_device *bdev, fmode_t mode)
 {
-	struct scsi_cd *cd;
+	struct scsi_cd *cd = scsi_cd_get(bdev->bd_disk);
 	int ret = -ENXIO;
 
-	mutex_lock(&sr_mutex);
-	cd = scsi_cd_get(bdev->bd_disk);
 	if (cd) {
 		ret = cdrom_open(&cd->cdi, bdev, mode);
 		if (ret)
 			scsi_cd_put(cd);
 	}
-	mutex_unlock(&sr_mutex);
 	return ret;
 }
 
 static void sr_block_release(struct gendisk *disk, fmode_t mode)
 {
 	struct scsi_cd *cd = scsi_cd(disk);
-	mutex_lock(&sr_mutex);
+
 	cdrom_release(&cd->cdi, mode);
 	scsi_cd_put(cd);
-	mutex_unlock(&sr_mutex);
 }
 
 static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
@@ -547,12 +542,10 @@ static int sr_block_ioctl(struct block_d
 	void __user *argp = (void __user *)arg;
 	int ret;
 
-	mutex_lock(&sr_mutex);
-
 	ret = scsi_ioctl_block_when_processing_errors(sdev, cmd,
 			(mode & FMODE_NDELAY) != 0);
 	if (ret)
-		goto out;
+		return ret;
 
 	/*
 	 * Send SCSI addressing ioctls directly to mid level, send other
@@ -561,19 +554,14 @@ static int sr_block_ioctl(struct block_d
 	switch (cmd) {
 	case SCSI_IOCTL_GET_IDLUN:
 	case SCSI_IOCTL_GET_BUS_NUMBER:
-		ret = scsi_ioctl(sdev, cmd, argp);
-		goto out;
+		return scsi_ioctl(sdev, cmd, argp);
 	}
 
 	ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, arg);
 	if (ret != -ENOSYS)
-		goto out;
+		return ret;
 
-	ret = scsi_ioctl(sdev, cmd, argp);
-
-out:
-	mutex_unlock(&sr_mutex);
-	return ret;
+	return scsi_ioctl(sdev, cmd, argp);
 }
 
 static unsigned int sr_block_check_events(struct gendisk *disk,
Signature · 3 lines
Stefan Richter
-=====-===== --=- ---=-
http://arcgraph.de/sr/
#5 lore raw
Quoted 11 lines · Stefan Richter
Quoted 6 lines · On Feb 01 Joe Perches wrote:
Quoted 5 lines · Stefan Richter
Quoted 4 lines · On Feb 01 Joe Perches wrote:
Quoted 3 lines · Stefan Richter
Quoted 3 lines

ERROR: Please use 12 or more chars for the git commit ID like: 'Commit 01234567890ab ("commit description")' #5:
Commit 2a48fc0ab242 "block: autoconvert trivial BKL users to private

[...]

Quoted 3 lines
Quoted 2 lines

Thanks for the tip; this works for me. (checkpatch.pl from current -next does actually not complain about the line without parentheses.)

Quoted 8 lines
Quoted 3 lines

Hmm, I think that should be a defect.

Can you send me your git format-patch output please?

First of all to be sure: The checkpatch.pl which I last referred to is 158501 bytes in size, and the md5sum is bf953e10cbd7405bcf3e885b24c832bd.

$ scripts/checkpatch.pl patches/scsi-sr-fix-multi-drive-performance-remove-bkl-replacement.patch 
total: 0 errors, 0 warnings, 71 lines checked

Thanks.
I think I "fixed" it with this patch:
https://lkml.org/lkml/2015/2/1/249

#6 lore raw
Quoted 4 lines · On Feb 01 Joe Perches wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines · Stefan Richter
Quoted 3 lines
Quoted 3 lines

ERROR: Please use 12 or more chars for the git commit ID like: 'Commit 01234567890ab ("commit description")' #5:
Commit 2a48fc0ab242 "block: autoconvert trivial BKL users to private

[...]

Quoted 2 lines

I think I "fixed" it with this patch:
https://lkml.org/lkml/2015/2/1/249

Confirmed.

Signature · 3 lines
Stefan Richter
-=====-===== --=- ---=-
http://arcgraph.de/sr/