From: "Thomas Maier" <balagi@justmail.de>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "petero2@telia.com" <petero2@telia.com>, "akpm@osdl.org" <akpm@osdl.org>
Subject: [PATCH 9/11] 2.6.18-mm3 pktcdvd: packet buffer control
Date: Tue, 03 Oct 2006 17:26:43 +0200 [thread overview]
Message-ID: <op.tguqitr2iudtyh@master> (raw)
[-- Attachment #1: Type: text/plain, Size: 284 bytes --]
Hello,
this patch allows to control the amount of packet buffers per
device.
See the Documentation/* files in the patch for further infos.
http://people.freenet.de/BalaGi/download/pktcdvd-9-packet-buffers_2.6.18.patch
Signed-off-by: Thomas Maier<balagi@justmail.de>
-Thomas Maier
[-- Attachment #2: pktcdvd-9-packet-buffers_2.6.18.patch --]
[-- Type: application/octet-stream, Size: 4645 bytes --]
diff -urpN 8-wqueue-congestion/Documentation/ABI/testing/sysfs-class-pktcdvd 9-packet-buffers/Documentation/ABI/testing/sysfs-class-pktcdvd
--- 8-wqueue-congestion/Documentation/ABI/testing/sysfs-class-pktcdvd 2006-10-03 15:46:49.000000000 +0200
+++ 9-packet-buffers/Documentation/ABI/testing/sysfs-class-pktcdvd 2006-10-03 13:48:22.000000000 +0200
@@ -22,6 +22,10 @@ these files in the sysfs:
device_map (0444) Shows the device mapping in format:
pktcdvd[0-7] <pktdevid> <blkdevid>
+
+ packet_buffers (0644) Number of concurrent packets per
+ pktcdvd device. Used for new created
+ devices.
/sys/class/pktcdvd/pktcdvd[0-7]/
dev (0444) Device id
diff -urpN 8-wqueue-congestion/drivers/block/pktcdvd.c 9-packet-buffers/drivers/block/pktcdvd.c
--- 8-wqueue-congestion/drivers/block/pktcdvd.c 2006-10-03 13:54:43.000000000 +0200
+++ 9-packet-buffers/drivers/block/pktcdvd.c 2006-10-03 13:54:54.000000000 +0200
@@ -90,6 +90,7 @@ static struct pktcdvd_device *pkt_devs[M
static int pktdev_major = 0; /* default: dynamic major number */
static int write_congestion_on = PKT_WRITE_CONGESTION_ON;
static int write_congestion_off = PKT_WRITE_CONGESTION_OFF;
+static int packet_buffers = PKT_BUFFERS_DEFAULT;
static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
static mempool_t *psd_pool;
@@ -152,6 +153,14 @@ static void init_write_congestion_marks(
}
}
+static void init_packet_buffers(int *n)
+{
+ if (*n < 1)
+ *n = 1;
+ else if (*n > 128)
+ *n = 128;
+}
+
static void pkt_count_states(struct pktcdvd_device *pd, int *states)
{
struct packet_data *pkt;
@@ -201,6 +210,7 @@ static int pkt_print_info(struct pktcdvd
else
msg = "Unknown";
PRINT("\tblock mode:\t\t%s\n", msg);
+ PRINT("\tconcurrent packets:\t%d\n", packet_buffers);
PRINT("\nStatistics:\n");
PRINT("\tpackets started:\t%lu\n", pd->stats.pkt_started);
@@ -465,6 +475,7 @@ static void pkt_sysfs_dev_remove(struct
add map block device
remove unmap packet dev
device_map show mappings
+ packet_buffers number of packet buffers per dev
*******************************************************************/
static void class_pktcdvd_release(struct class *cls)
@@ -491,6 +502,11 @@ static ssize_t class_pktcdvd_show_map(st
return n;
}
+static ssize_t class_pktcdvd_show_pb(struct class *c, char *data)
+{
+ return sprintf(data, "%d\n", packet_buffers);
+}
+
static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
size_t count)
{
@@ -515,10 +531,26 @@ static ssize_t class_pktcdvd_store_remov
return -EINVAL;
}
+static ssize_t class_pktcdvd_store_pb(struct class *c, const char *buf,
+ size_t count)
+{
+ int val;
+ DECLARE_BUF_AS_STRING(dbuf, buf, count);
+ if (sscanf(dbuf, "%d", &val) == 1) {
+ mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
+ init_packet_buffers(&val);
+ packet_buffers = val;
+ mutex_unlock(&ctl_mutex);
+ return count;
+ }
+ return -EINVAL;
+}
+
static struct class_attribute class_pktcdvd_attrs[] = {
__ATTR(add, 0200, NULL, class_pktcdvd_store_add),
__ATTR(remove, 0200, NULL, class_pktcdvd_store_remove),
__ATTR(device_map, 0444, class_pktcdvd_show_map, NULL),
+ __ATTR(packet_buffers, 0644, class_pktcdvd_show_pb, class_pktcdvd_store_pb),
__ATTR_NULL
};
@@ -2603,7 +2635,7 @@ static int pkt_open_dev(struct pktcdvd_d
goto out_unclaim;
if (write) {
- if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) {
+ if (!pkt_grow_pktlist(pd, packet_buffers)) {
printk(DRIVER_NAME": not enough memory for buffers\n");
ret = -ENOMEM;
goto out_unclaim;
@@ -3180,6 +3212,7 @@ static int __init pkt_init(void)
init_write_congestion_marks(&write_congestion_off,
&write_congestion_on);
+ init_packet_buffers(&packet_buffers);
mutex_init(&ctl_mutex);
diff -urpN 8-wqueue-congestion/include/linux/pktcdvd.h 9-packet-buffers/include/linux/pktcdvd.h
--- 8-wqueue-congestion/include/linux/pktcdvd.h 2006-10-03 13:37:01.000000000 +0200
+++ 9-packet-buffers/include/linux/pktcdvd.h 2006-10-03 13:47:56.000000000 +0200
@@ -122,6 +122,13 @@ struct pkt_ctrl_command {
#define PKT_USE_PROCFS 0
#endif
+/* use concurrent packets per device */
+#ifdef CONFIG_CDROM_PKTCDVD_BUFFERS
+#define PKT_BUFFERS_DEFAULT CONFIG_CDROM_PKTCDVD_BUFFERS
+#else
+#define PKT_BUFFERS_DEFAULT 8
+#endif
+
/* default bio write queue congestion marks */
#define PKT_WRITE_CONGESTION_ON 5000
reply other threads:[~2006-10-03 15:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=op.tguqitr2iudtyh@master \
--to=balagi@justmail.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=petero2@telia.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.