netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arch: um: convert tasklets to use new tasklet_setup() API
@ 2020-08-17  9:15 Allen Pais
  2020-08-17  9:15 ` [PATCH] block: " Allen Pais
                   ` (18 more replies)
  0 siblings, 19 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:15 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 arch/um/drivers/vector_kern.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 8735c468230a..06980870ae23 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -1196,9 +1196,9 @@ static int vector_net_close(struct net_device *dev)
 
 /* TX tasklet */
 
-static void vector_tx_poll(unsigned long data)
+static void vector_tx_poll(struct tasklet_struct *t)
 {
-	struct vector_private *vp = (struct vector_private *)data;
+	struct vector_private *vp = from_tasklet(vp, t, tx_poll);
 
 	vp->estats.tx_kicks++;
 	vector_send(vp->tx_queue);
@@ -1629,7 +1629,7 @@ static void vector_eth_configure(
 	});
 
 	dev->features = dev->hw_features = (NETIF_F_SG | NETIF_F_FRAGLIST);
-	tasklet_init(&vp->tx_poll, vector_tx_poll, (unsigned long)vp);
+	tasklet_setup(&vp->tx_poll, vector_tx_poll);
 	INIT_WORK(&vp->reset_tx, vector_reset_tx);
 
 	timer_setup(&vp->tl, vector_timer_expire, 0);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
@ 2020-08-17  9:15 ` Allen Pais
  2020-08-17 13:56   ` Jens Axboe
  2020-08-17  9:15 ` [PATCH] char: ipmi: " Allen Pais
                   ` (17 subsequent siblings)
  18 siblings, 1 reply; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:15 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/block/umem.c    | 6 +++---
 drivers/block/xsysace.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index 2b95d7b33b91..320781d5d156 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -405,7 +405,7 @@ static int add_bio(struct cardinfo *card)
 	return 1;
 }
 
-static void process_page(unsigned long data)
+static void process_page(struct tasklet_struct *t)
 {
 	/* check if any of the requests in the page are DMA_COMPLETE,
 	 * and deal with them appropriately.
@@ -415,7 +415,7 @@ static void process_page(unsigned long data)
 	 */
 	struct mm_page *page;
 	struct bio *return_bio = NULL;
-	struct cardinfo *card = (struct cardinfo *)data;
+	struct cardinfo *card = from_tasklet(card, t, tasklet);
 	unsigned int dma_status = card->dma_status;
 
 	spin_lock(&card->lock);
@@ -891,7 +891,7 @@ static int mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	if (!card->queue)
 		goto failed_alloc;
 
-	tasklet_init(&card->tasklet, process_page, (unsigned long)card);
+	tasklet_setup(&card->tasklet, process_page);
 
 	card->check_batteries = 0;
 
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 5d8e0ab3f054..bdd50a87d10f 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -762,9 +762,9 @@ static void ace_fsm_dostate(struct ace_device *ace)
 	}
 }
 
-static void ace_fsm_tasklet(unsigned long data)
+static void ace_fsm_tasklet(struct tasklet_struct *t)
 {
-	struct ace_device *ace = (void *)data;
+	struct ace_device *ace = from_tasklet(ace, t, fsm_tasklet);
 	unsigned long flags;
 
 	spin_lock_irqsave(&ace->lock, flags);
@@ -1001,7 +1001,7 @@ static int ace_setup(struct ace_device *ace)
 	/*
 	 * Initialize the state machine tasklet and stall timer
 	 */
-	tasklet_init(&ace->fsm_tasklet, ace_fsm_tasklet, (unsigned long)ace);
+	tasklet_setup(&ace->fsm_tasklet, ace_fsm_tasklet);
 	timer_setup(&ace->stall_timer, ace_stall_timer, 0);
 
 	/*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] char: ipmi: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
  2020-08-17  9:15 ` [PATCH] block: " Allen Pais
@ 2020-08-17  9:15 ` Allen Pais
  2020-08-17 12:15   ` Corey Minyard
  2020-08-17  9:15 ` [PATCH] driver: hv: " Allen Pais
                   ` (16 subsequent siblings)
  18 siblings, 1 reply; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:15 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/char/ipmi/ipmi_msghandler.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 737c0b6b24ea..e1814b6a1225 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -39,7 +39,7 @@
 
 static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
 static int ipmi_init_msghandler(void);
-static void smi_recv_tasklet(unsigned long);
+static void smi_recv_tasklet(struct tasklet_struct *t);
 static void handle_new_recv_msgs(struct ipmi_smi *intf);
 static void need_waiter(struct ipmi_smi *intf);
 static int handle_one_recv_msg(struct ipmi_smi *intf,
@@ -3430,9 +3430,8 @@ int ipmi_add_smi(struct module         *owner,
 	intf->curr_seq = 0;
 	spin_lock_init(&intf->waiting_rcv_msgs_lock);
 	INIT_LIST_HEAD(&intf->waiting_rcv_msgs);
-	tasklet_init(&intf->recv_tasklet,
-		     smi_recv_tasklet,
-		     (unsigned long) intf);
+	tasklet_setup(&intf->recv_tasklet,
+		     smi_recv_tasklet);
 	atomic_set(&intf->watchdog_pretimeouts_to_deliver, 0);
 	spin_lock_init(&intf->xmit_msgs_lock);
 	INIT_LIST_HEAD(&intf->xmit_msgs);
@@ -4467,10 +4466,10 @@ static void handle_new_recv_msgs(struct ipmi_smi *intf)
 	}
 }
 
-static void smi_recv_tasklet(unsigned long val)
+static void smi_recv_tasklet(struct tasklet_struct *t)
 {
 	unsigned long flags = 0; /* keep us warning-free. */
-	struct ipmi_smi *intf = (struct ipmi_smi *) val;
+	struct ipmi_smi *intf = from_tasklet(intf, t, recv_tasklet);
 	int run_to_completion = intf->run_to_completion;
 	struct ipmi_smi_msg *newmsg = NULL;
 
@@ -4542,7 +4541,7 @@ void ipmi_smi_msg_received(struct ipmi_smi *intf,
 		spin_unlock_irqrestore(&intf->xmit_msgs_lock, flags);
 
 	if (run_to_completion)
-		smi_recv_tasklet((unsigned long) intf);
+		smi_recv_tasklet(&intf->recv_tasklet);
 	else
 		tasklet_schedule(&intf->recv_tasklet);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] driver: hv: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
  2020-08-17  9:15 ` [PATCH] block: " Allen Pais
  2020-08-17  9:15 ` [PATCH] char: ipmi: " Allen Pais
@ 2020-08-17  9:15 ` Allen Pais
  2020-08-17  9:15 ` [PATCH] drivers: atm: " Allen Pais
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:15 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/hv/channel_mgmt.c | 3 +--
 drivers/hv/connection.c   | 4 ++--
 drivers/hv/hv.c           | 3 +--
 drivers/hv/hyperv_vmbus.h | 4 ++--
 drivers/hv/vmbus_drv.c    | 4 ++--
 5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 591106cf58fc..640fc1688d49 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -321,8 +321,7 @@ static struct vmbus_channel *alloc_channel(void)
 
 	INIT_LIST_HEAD(&channel->sc_list);
 
-	tasklet_init(&channel->callback_event,
-		     vmbus_on_event, (unsigned long)channel);
+	tasklet_setup(&channel->callback_event, vmbus_on_event);
 
 	hv_ringbuffer_pre_init(channel);
 
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 11170d9a2e1a..23e10ebecf5c 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -322,9 +322,9 @@ struct vmbus_channel *relid2channel(u32 relid)
  *    If this tasklet has been running for a long time
  *    then reschedule ourselves.
  */
-void vmbus_on_event(unsigned long data)
+void vmbus_on_event(struct tasklet_struct *t)
 {
-	struct vmbus_channel *channel = (void *) data;
+	struct vmbus_channel *channel = from_tasklet(channel, t, callback_event);
 	unsigned long time_limit = jiffies + 2;
 
 	trace_vmbus_on_event(channel);
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index da69338f92f5..91a0582387d6 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -96,8 +96,7 @@ int hv_synic_alloc(void)
 	for_each_present_cpu(cpu) {
 		hv_cpu = per_cpu_ptr(hv_context.cpu_context, cpu);
 
-		tasklet_init(&hv_cpu->msg_dpc,
-			     vmbus_on_msg_dpc, (unsigned long) hv_cpu);
+		tasklet_setup(&hv_cpu->msg_dpc, vmbus_on_msg_dpc);
 
 		hv_cpu->synic_message_page =
 			(void *)get_zeroed_page(GFP_ATOMIC);
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 40e2b9f91163..36199d8ea8c3 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -351,8 +351,8 @@ void vmbus_disconnect(void);
 
 int vmbus_post_msg(void *buffer, size_t buflen, bool can_sleep);
 
-void vmbus_on_event(unsigned long data);
-void vmbus_on_msg_dpc(unsigned long data);
+void vmbus_on_event(struct tasklet_struct *t);
+void vmbus_on_msg_dpc(struct tasklet_struct *t);
 
 int hv_kvp_init(struct hv_util_service *srv);
 void hv_kvp_deinit(void);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 910b6e90866c..6b7987dac97a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1043,9 +1043,9 @@ static void vmbus_onmessage_work(struct work_struct *work)
 	kfree(ctx);
 }
 
-void vmbus_on_msg_dpc(unsigned long data)
+void vmbus_on_msg_dpc(struct tasklet_struct *t)
 {
-	struct hv_per_cpu_context *hv_cpu = (void *)data;
+	struct hv_per_cpu_context *hv_cpu = from_tasklet(hv_cpu, t, msg_dpc);
 	void *page_addr = hv_cpu->synic_message_page;
 	struct hv_message *msg = (struct hv_message *)page_addr +
 				  VMBUS_MESSAGE_SINT;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] drivers: atm: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (2 preceding siblings ...)
  2020-08-17  9:15 ` [PATCH] driver: hv: " Allen Pais
@ 2020-08-17  9:15 ` Allen Pais
  2020-08-17  9:16 ` [PATCH] drivers: ntb: " Allen Pais
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:15 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/atm/eni.c       |  9 +++++----
 drivers/atm/fore200e.c  | 14 +++++++-------
 drivers/atm/he.c        |  8 ++++----
 drivers/atm/solos-pci.c |  8 ++++----
 4 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index 39be444534d0..540edea0ad7a 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -1521,10 +1521,11 @@ static irqreturn_t eni_int(int irq,void *dev_id)
 }
 
 
-static void eni_tasklet(unsigned long data)
+static void eni_tasklet(struct tasklet_struct *t)
 {
-	struct atm_dev *dev = (struct atm_dev *) data;
-	struct eni_dev *eni_dev = ENI_DEV(dev);
+	struct eni_dev *eni_dev = from_tasklet(eni_dev, t, task);
+	struct atm_dev *dev = container_of((void *)eni_dev, typeof(*dev),
+					  dev_data);
 	unsigned long flags;
 	u32 events;
 
@@ -1838,7 +1839,7 @@ static int eni_start(struct atm_dev *dev)
 	     eni_dev->vci,eni_dev->rx_dma,eni_dev->tx_dma,
 	     eni_dev->service,buf);
 	spin_lock_init(&eni_dev->lock);
-	tasklet_init(&eni_dev->task,eni_tasklet,(unsigned long) dev);
+	tasklet_setup(&eni_dev->task,eni_tasklet);
 	eni_dev->events = 0;
 	/* initialize memory management */
 	buffer_mem = eni_dev->mem - (buf - eni_dev->ram);
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index a81bc49c14ac..8c6226b50e4d 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -1180,9 +1180,9 @@ fore200e_interrupt(int irq, void* dev)
 
 #ifdef FORE200E_USE_TASKLET
 static void
-fore200e_tx_tasklet(unsigned long data)
+fore200e_tx_tasklet(struct tasklet_struct *t)
 {
-    struct fore200e* fore200e = (struct fore200e*) data;
+    struct fore200e* fore200e = from_tasklet(fore200e, t, tx_tasklet);
     unsigned long flags;
 
     DPRINTK(3, "tx tasklet scheduled for device %d\n", fore200e->atm_dev->number);
@@ -1194,15 +1194,15 @@ fore200e_tx_tasklet(unsigned long data)
 
 
 static void
-fore200e_rx_tasklet(unsigned long data)
+fore200e_rx_tasklet(struct tasklet_struct *t)
 {
-    struct fore200e* fore200e = (struct fore200e*) data;
+    struct fore200e* fore200e = from_tasklet(fore200e, t, rx_tasklet);
     unsigned long    flags;
 
     DPRINTK(3, "rx tasklet scheduled for device %d\n", fore200e->atm_dev->number);
 
     spin_lock_irqsave(&fore200e->q_lock, flags);
-    fore200e_rx_irq((struct fore200e*) data);
+    fore200e_rx_irq(fore200e);
     spin_unlock_irqrestore(&fore200e->q_lock, flags);
 }
 #endif
@@ -1943,8 +1943,8 @@ static int fore200e_irq_request(struct fore200e *fore200e)
 	   fore200e_irq_itoa(fore200e->irq), fore200e->name);
 
 #ifdef FORE200E_USE_TASKLET
-    tasklet_init(&fore200e->tx_tasklet, fore200e_tx_tasklet, (unsigned long)fore200e);
-    tasklet_init(&fore200e->rx_tasklet, fore200e_rx_tasklet, (unsigned long)fore200e);
+    tasklet_setup(&fore200e->tx_tasklet, fore200e_tx_tasklet);
+    tasklet_setup(&fore200e->rx_tasklet, fore200e_rx_tasklet);
 #endif
 
     fore200e->state = FORE200E_STATE_IRQ;
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index 8af793f5e811..9c36fea4336f 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -100,7 +100,7 @@ static void he_close(struct atm_vcc *vcc);
 static int he_send(struct atm_vcc *vcc, struct sk_buff *skb);
 static int he_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg);
 static irqreturn_t he_irq_handler(int irq, void *dev_id);
-static void he_tasklet(unsigned long data);
+static void he_tasklet(struct tasklet_struct *t);
 static int he_proc_read(struct atm_dev *dev,loff_t *pos,char *page);
 static int he_start(struct atm_dev *dev);
 static void he_stop(struct he_dev *dev);
@@ -383,7 +383,7 @@ static int he_init_one(struct pci_dev *pci_dev,
 	he_dev->atm_dev->dev_data = he_dev;
 	atm_dev->dev_data = he_dev;
 	he_dev->number = atm_dev->number;
-	tasklet_init(&he_dev->tasklet, he_tasklet, (unsigned long) he_dev);
+	tasklet_setup(&he_dev->tasklet, he_tasklet);
 	spin_lock_init(&he_dev->global_lock);
 
 	if (he_start(atm_dev)) {
@@ -1925,10 +1925,10 @@ he_service_rbpl(struct he_dev *he_dev, int group)
 }
 
 static void
-he_tasklet(unsigned long data)
+he_tasklet(struct tasklet_struct *t)
 {
 	unsigned long flags;
-	struct he_dev *he_dev = (struct he_dev *) data;
+	struct he_dev *he_dev = from_tasklet(he_dev, t, tasklet);
 	int group, type;
 	int updated = 0;
 
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 94fbc3abe60e..f44e1880cb74 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -167,7 +167,7 @@ static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci);
 static int atm_init(struct solos_card *, struct device *);
 static void atm_remove(struct solos_card *);
 static int send_command(struct solos_card *card, int dev, const char *buf, size_t size);
-static void solos_bh(unsigned long);
+static void solos_bh(struct tasklet_struct *t);
 static int print_buffer(struct sk_buff *buf);
 
 static inline void solos_pop(struct atm_vcc *vcc, struct sk_buff *skb)
@@ -754,9 +754,9 @@ static irqreturn_t solos_irq(int irq, void *dev_id)
 	return IRQ_RETVAL(handled);
 }
 
-static void solos_bh(unsigned long card_arg)
+static void solos_bh(struct tasklet_struct *t)
 {
-	struct solos_card *card = (void *)card_arg;
+	struct solos_card *card = from_tasklet(card, t, tlet);
 	uint32_t card_flags;
 	uint32_t rx_done = 0;
 	int port;
@@ -1294,7 +1294,7 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
 	pci_set_drvdata(dev, card);
 
-	tasklet_init(&card->tlet, solos_bh, (unsigned long)card);
+	tasklet_setup(&card->tlet, solos_bh);
 	spin_lock_init(&card->tx_lock);
 	spin_lock_init(&card->tx_queue_lock);
 	spin_lock_init(&card->cli_queue_lock);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] drivers: ntb: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (3 preceding siblings ...)
  2020-08-17  9:15 ` [PATCH] drivers: atm: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH] drivers: rapidio: " Allen Pais
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/ntb/ntb_transport.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index e6d1f5b298f3..ab3bee2fc803 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -273,7 +273,7 @@ enum {
 #define NTB_QP_DEF_NUM_ENTRIES	100
 #define NTB_LINK_DOWN_TIMEOUT	10
 
-static void ntb_transport_rxc_db(unsigned long data);
+static void ntb_transport_rxc_db(struct tasklet_struct *t);
 static const struct ntb_ctx_ops ntb_transport_ops;
 static struct ntb_client ntb_transport_client;
 static int ntb_async_tx_submit(struct ntb_transport_qp *qp,
@@ -1234,8 +1234,7 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt,
 	INIT_LIST_HEAD(&qp->rx_free_q);
 	INIT_LIST_HEAD(&qp->tx_free_q);
 
-	tasklet_init(&qp->rxc_db_work, ntb_transport_rxc_db,
-		     (unsigned long)qp);
+	tasklet_setup(&qp->rxc_db_work, ntb_transport_rxc_db);
 
 	return 0;
 }
@@ -1685,9 +1684,9 @@ static int ntb_process_rxc(struct ntb_transport_qp *qp)
 	return 0;
 }
 
-static void ntb_transport_rxc_db(unsigned long data)
+static void ntb_transport_rxc_db(struct tasklet_struct *t)
 {
-	struct ntb_transport_qp *qp = (void *)data;
+	struct ntb_transport_qp *qp = from_tasklet(qp, t, rxc_db_work);
 	int rc, i;
 
 	dev_dbg(&qp->ndev->pdev->dev, "%s: doorbell %d received\n",
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] drivers: rapidio: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (4 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH] drivers: ntb: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH] drivers: s390: " Allen Pais
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/rapidio/devices/tsi721_dma.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/rapidio/devices/tsi721_dma.c b/drivers/rapidio/devices/tsi721_dma.c
index d375c02059f3..4a2bb6d7c692 100644
--- a/drivers/rapidio/devices/tsi721_dma.c
+++ b/drivers/rapidio/devices/tsi721_dma.c
@@ -566,9 +566,9 @@ static void tsi721_advance_work(struct tsi721_bdma_chan *bdma_chan,
 		  bdma_chan->id);
 }
 
-static void tsi721_dma_tasklet(unsigned long data)
+static void tsi721_dma_tasklet(struct tasklet_struct *t)
 {
-	struct tsi721_bdma_chan *bdma_chan = (struct tsi721_bdma_chan *)data;
+	struct tsi721_bdma_chan *bdma_chan = from_tasklet(bdma_chan, t, tasklet);
 	u32 dmac_int, dmac_sts;
 
 	dmac_int = ioread32(bdma_chan->regs + TSI721_DMAC_INT);
@@ -988,8 +988,7 @@ int tsi721_register_dma(struct tsi721_device *priv)
 		INIT_LIST_HEAD(&bdma_chan->queue);
 		INIT_LIST_HEAD(&bdma_chan->free_list);
 
-		tasklet_init(&bdma_chan->tasklet, tsi721_dma_tasklet,
-			     (unsigned long)bdma_chan);
+		tasklet_setup(&bdma_chan->tasklet, tsi721_dma_tasklet);
 		list_add_tail(&bdma_chan->dchan.device_node,
 			      &mport->dma.channels);
 		nr_channels++;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] drivers: s390: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (5 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH] drivers: rapidio: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH] drivers: vme: " Allen Pais
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/s390/block/dasd.c     | 18 ++++++++----------
 drivers/s390/char/con3215.c   |  6 +++---
 drivers/s390/char/con3270.c   |  7 +++----
 drivers/s390/char/tty3270.c   | 15 +++++++--------
 drivers/s390/cio/qdio.h       |  6 +++---
 drivers/s390/cio/qdio_main.c  | 12 ++++++------
 drivers/s390/cio/qdio_setup.c |  9 +++------
 drivers/s390/net/ctcm_main.c  |  8 +++-----
 drivers/s390/net/ctcm_mpc.c   | 16 ++++++++--------
 drivers/s390/net/ctcm_mpc.h   |  6 +++---
 10 files changed, 47 insertions(+), 56 deletions(-)

diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index eb17fea8075c..ec0d8a4ed05f 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -72,8 +72,8 @@ MODULE_LICENSE("GPL");
 static int  dasd_alloc_queue(struct dasd_block *);
 static void dasd_free_queue(struct dasd_block *);
 static int dasd_flush_block_queue(struct dasd_block *);
-static void dasd_device_tasklet(unsigned long);
-static void dasd_block_tasklet(unsigned long);
+static void dasd_device_tasklet(struct tasklet_struct *);
+static void dasd_block_tasklet(struct tasklet_struct *);
 static void do_kick_device(struct work_struct *);
 static void do_restore_device(struct work_struct *);
 static void do_reload_device(struct work_struct *);
@@ -133,8 +133,7 @@ struct dasd_device *dasd_alloc_device(void)
 	dasd_init_chunklist(&device->ese_chunks, device->ese_mem, PAGE_SIZE * 2);
 	spin_lock_init(&device->mem_lock);
 	atomic_set(&device->tasklet_scheduled, 0);
-	tasklet_init(&device->tasklet, dasd_device_tasklet,
-		     (unsigned long) device);
+	tasklet_setup(&device->tasklet, dasd_device_tasklet);
 	INIT_LIST_HEAD(&device->ccw_queue);
 	timer_setup(&device->timer, dasd_device_timeout, 0);
 	INIT_WORK(&device->kick_work, do_kick_device);
@@ -174,8 +173,7 @@ struct dasd_block *dasd_alloc_block(void)
 	atomic_set(&block->open_count, -1);
 
 	atomic_set(&block->tasklet_scheduled, 0);
-	tasklet_init(&block->tasklet, dasd_block_tasklet,
-		     (unsigned long) block);
+	tasklet_setup(&block->tasklet, dasd_block_tasklet);
 	INIT_LIST_HEAD(&block->ccw_queue);
 	spin_lock_init(&block->queue_lock);
 	INIT_LIST_HEAD(&block->format_list);
@@ -2187,9 +2185,9 @@ EXPORT_SYMBOL_GPL(dasd_flush_device_queue);
 /*
  * Acquire the device lock and process queues for the device.
  */
-static void dasd_device_tasklet(unsigned long data)
+static void dasd_device_tasklet(struct tasklet_struct *t)
 {
-	struct dasd_device *device = (struct dasd_device *) data;
+	struct dasd_device *device = from_tasklet(device, t, tasklet);
 	struct list_head final_queue;
 
 	atomic_set (&device->tasklet_scheduled, 0);
@@ -2929,9 +2927,9 @@ static void __dasd_block_start_head(struct dasd_block *block)
  * block layer request queue, creates ccw requests, enqueues them on
  * a dasd_device and processes ccw requests that have been returned.
  */
-static void dasd_block_tasklet(unsigned long data)
+static void dasd_block_tasklet(struct tasklet_struct *t)
 {
-	struct dasd_block *block = (struct dasd_block *) data;
+	struct dasd_block *block = from_tasklet(block, t, tasklet);
 	struct list_head final_queue;
 	struct list_head *l, *n;
 	struct dasd_ccw_req *cqr;
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 92757f9bd010..ab5964cffb91 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -334,9 +334,9 @@ static inline void raw3215_try_io(struct raw3215_info *raw)
 /*
  * Call tty_wakeup from tasklet context
  */
-static void raw3215_wakeup(unsigned long data)
+static void raw3215_wakeup(struct tasklet_struct *t)
 {
-	struct raw3215_info *raw = (struct raw3215_info *) data;
+	struct raw3215_info *raw = from_tasklet(raw, t, tlet);
 	struct tty_struct *tty;
 
 	tty = tty_port_tty_get(&raw->port);
@@ -673,7 +673,7 @@ static struct raw3215_info *raw3215_alloc_info(void)
 
 	timer_setup(&info->timer, raw3215_timeout, 0);
 	init_waitqueue_head(&info->empty_wait);
-	tasklet_init(&info->tlet, raw3215_wakeup, (unsigned long)info);
+	tasklet_setup(&info->tlet, raw3215_wakeup);
 	tty_port_init(&info->port);
 
 	return info;
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
index e17364e13d2f..02de4281d5b7 100644
--- a/drivers/s390/char/con3270.c
+++ b/drivers/s390/char/con3270.c
@@ -291,8 +291,9 @@ con3270_update(struct timer_list *t)
  * Read tasklet.
  */
 static void
-con3270_read_tasklet(struct raw3270_request *rrq)
+con3270_read_tasklet(struct tasklet_struct *t)
 {
+	struct raw3270_request *rrq = condev->read;
 	static char kreset_data = TW_KR;
 	struct con3270 *cp;
 	unsigned long flags;
@@ -625,9 +626,7 @@ con3270_init(void)
 	INIT_LIST_HEAD(&condev->lines);
 	INIT_LIST_HEAD(&condev->update);
 	timer_setup(&condev->timer, con3270_update, 0);
-	tasklet_init(&condev->readlet, 
-		     (void (*)(unsigned long)) con3270_read_tasklet,
-		     (unsigned long) condev->read);
+	tasklet_setup(&condev->readlet, con3270_read_tasklet);
 
 	raw3270_add_view(&condev->view, &con3270_fn, 1, RAW3270_VIEW_LOCK_IRQ);
 
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index aec996de44d9..fa8040e3840d 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -556,9 +556,10 @@ tty3270_scroll_backward(struct kbd_data *kbd)
  * Pass input line to tty.
  */
 static void
-tty3270_read_tasklet(unsigned long data)
+tty3270_read_tasklet(struct tasklet_struct *t)
 {
-	struct raw3270_request *rrq = (struct raw3270_request *)data;
+	struct tty3270 *tp = from_tasklet(tp, t, readlet)
+	struct raw3270_request *rrq = tp->read;
 	static char kreset_data = TW_KR;
 	struct tty3270 *tp = container_of(rrq->view, struct tty3270, view);
 	char *input;
@@ -653,9 +654,9 @@ tty3270_issue_read(struct tty3270 *tp, int lock)
  * Hang up the tty
  */
 static void
-tty3270_hangup_tasklet(unsigned long data)
+tty3270_hangup_tasklet(struct tasklet_struct *t)
 {
-	struct tty3270 *tp = (struct tty3270 *)data;
+	struct tty3270 *tp = from_tasklet(tp, t, hanglet);
 	tty_port_tty_hangup(&tp->port, true);
 	raw3270_put_view(&tp->view);
 }
@@ -754,10 +755,8 @@ tty3270_alloc_view(void)
 
 	tty_port_init(&tp->port);
 	timer_setup(&tp->timer, tty3270_update, 0);
-	tasklet_init(&tp->readlet, tty3270_read_tasklet,
-		     (unsigned long) tp->read);
-	tasklet_init(&tp->hanglet, tty3270_hangup_tasklet,
-		     (unsigned long) tp);
+	tasklet_setup(&tp->readlet, tty3270_read_tasklet);
+	tasklet_setup(&tp->hanglet, tty3270_hangup_tasklet);
 	INIT_WORK(&tp->resize_work, tty3270_resize_work);
 
 	return tp;
diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
index cd2df4ff8e0e..ac845a1002f0 100644
--- a/drivers/s390/cio/qdio.h
+++ b/drivers/s390/cio/qdio.h
@@ -359,14 +359,14 @@ int qdio_establish_thinint(struct qdio_irq *irq_ptr);
 void qdio_shutdown_thinint(struct qdio_irq *irq_ptr);
 void tiqdio_add_device(struct qdio_irq *irq_ptr);
 void tiqdio_remove_device(struct qdio_irq *irq_ptr);
-void tiqdio_inbound_processing(unsigned long q);
+void tiqdio_inbound_processing(struct tasklet_struct *t);
 int qdio_thinint_init(void);
 void qdio_thinint_exit(void);
 int test_nonshared_ind(struct qdio_irq *);
 
 /* prototypes for setup */
-void qdio_inbound_processing(unsigned long data);
-void qdio_outbound_processing(unsigned long data);
+void qdio_inbound_processing(struct tasklet_struct *t);
+void qdio_outbound_processing(struct tasklet_struct *t);
 void qdio_outbound_timer(struct timer_list *t);
 void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm,
 		      struct irb *irb);
diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
index 4fab8bba2cdd..b6ae13c5220f 100644
--- a/drivers/s390/cio/qdio_main.c
+++ b/drivers/s390/cio/qdio_main.c
@@ -634,9 +634,9 @@ static void __qdio_inbound_processing(struct qdio_q *q)
 	}
 }
 
-void qdio_inbound_processing(unsigned long data)
+void qdio_inbound_processing(struct tasklet_struct *t)
 {
-	struct qdio_q *q = (struct qdio_q *)data;
+	struct qdio_q *q = from_tasklet(q, t, tasklet);
 	__qdio_inbound_processing(q);
 }
 
@@ -801,9 +801,9 @@ static void __qdio_outbound_processing(struct qdio_q *q)
 }
 
 /* outbound tasklet */
-void qdio_outbound_processing(unsigned long data)
+void qdio_outbound_processing(struct tasklet_struct *t)
 {
-	struct qdio_q *q = (struct qdio_q *)data;
+	struct qdio_q *q = from_tasklet(q, t, tasklet);
 	__qdio_outbound_processing(q);
 }
 
@@ -827,9 +827,9 @@ static inline void qdio_check_outbound_pci_queues(struct qdio_irq *irq)
 			qdio_tasklet_schedule(out);
 }
 
-void tiqdio_inbound_processing(unsigned long data)
+void tiqdio_inbound_processing(struct tasklet_struct *t)
 {
-	struct qdio_q *q = (struct qdio_q *)data;
+	struct qdio_q *q = from_tasklet(q, t, tasklet);
 
 	if (need_siga_sync(q) && need_siga_sync_after_ai(q))
 		qdio_sync_queues(q);
diff --git a/drivers/s390/cio/qdio_setup.c b/drivers/s390/cio/qdio_setup.c
index 2c5cc6ec668e..cc80c37ba2e2 100644
--- a/drivers/s390/cio/qdio_setup.c
+++ b/drivers/s390/cio/qdio_setup.c
@@ -259,11 +259,9 @@ static void setup_queues(struct qdio_irq *irq_ptr,
 				    qdio_init->input_sbal_addr_array[i], i);
 
 		if (is_thinint_irq(irq_ptr)) {
-			tasklet_init(&q->tasklet, tiqdio_inbound_processing,
-				     (unsigned long) q);
+			tasklet_setup(&q->tasklet, tiqdio_inbound_processing);
 		} else {
-			tasklet_init(&q->tasklet, qdio_inbound_processing,
-				     (unsigned long) q);
+			tasklet_setup(&q->tasklet, qdio_inbound_processing);
 		}
 	}
 
@@ -278,8 +276,7 @@ static void setup_queues(struct qdio_irq *irq_ptr,
 		setup_storage_lists(q, irq_ptr,
 				    qdio_init->output_sbal_addr_array[i], i);
 
-		tasklet_init(&q->tasklet, qdio_outbound_processing,
-			     (unsigned long) q);
+		tasklet_setup(&q->tasklet, qdio_outbound_processing);
 		timer_setup(&q->u.out.timer, qdio_outbound_timer, 0);
 	}
 }
diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
index d06809eac16d..475ee3bcf3ae 100644
--- a/drivers/s390/net/ctcm_main.c
+++ b/drivers/s390/net/ctcm_main.c
@@ -1165,8 +1165,7 @@ static struct net_device *ctcm_init_netdevice(struct ctcm_priv *priv)
 			free_netdev(dev);
 			return NULL;
 		}
-		tasklet_init(&grp->mpc_tasklet2,
-				mpc_group_ready, (unsigned long)dev);
+		tasklet_setup(&grp->mpc_tasklet2, mpc_group_ready);
 		dev->mtu = MPC_BUFSIZE_DEFAULT -
 				TH_HEADER_LENGTH - PDU_HEADER_LENGTH;
 
@@ -1366,10 +1365,9 @@ static int add_channel(struct ccw_device *cdev, enum ctcm_channel_types type,
 					goto nomem_return;
 
 		ch->discontact_th->th_blk_flag = TH_DISCONTACT;
-		tasklet_init(&ch->ch_disc_tasklet,
-			mpc_action_send_discontact, (unsigned long)ch);
+		tasklet_setup(&ch->ch_disc_tasklet, mpc_action_send_discontact);
 
-		tasklet_init(&ch->ch_tasklet, ctcmpc_bh, (unsigned long)ch);
+		tasklet_setup(&ch->ch_tasklet, ctcmpc_bh);
 		ch->max_bufsize = (MPC_BUFSIZE_DEFAULT - 35);
 		ccw_num = 17;
 	} else
diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c
index ab316baa8284..049b6ca0789f 100644
--- a/drivers/s390/net/ctcm_mpc.c
+++ b/drivers/s390/net/ctcm_mpc.c
@@ -870,11 +870,11 @@ static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg)
  * helper of ctcm_init_netdevice
  * CTCM_PROTO_MPC only
  */
-void mpc_group_ready(unsigned long adev)
+void mpc_group_ready(struct tasklet_struct *t)
 {
-	struct net_device *dev = (struct net_device *)adev;
-	struct ctcm_priv *priv = dev->ml_priv;
-	struct mpc_group *grp = priv->mpcg;
+	struct mpc_group *grp = from_tasklet(grp, t, mpc_tasklet2);
+	struct ctcm_priv *priv = container_of(grp, typeof(*priv), mpcg);
+	struct net_device *dev = container_of(priv, typeof(*dev), ml_priv);
 	struct channel *ch = NULL;
 
 	if (grp == NULL) {
@@ -1233,9 +1233,9 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
  * Throttling back channel can result in excessive
  * channel inactivity and system deact of channel
  */
-void ctcmpc_bh(unsigned long thischan)
+void ctcmpc_bh(struct tasklet_struct *t)
 {
-	struct channel	  *ch	= (struct channel *)thischan;
+	struct channel	  *ch	= from_tasklet(ch, t, ch_tasklet);
 	struct sk_buff	  *skb;
 	struct net_device *dev	= ch->netdev;
 	struct ctcm_priv  *priv	= dev->ml_priv;
@@ -1516,10 +1516,10 @@ void mpc_action_discontact(fsm_instance *fi, int event, void *arg)
  * CTCM_PROTO_MPC only
  * called from add_channel in ctcm_main.c
  */
-void mpc_action_send_discontact(unsigned long thischan)
+void mpc_action_send_discontact(struct tasklet_struct *t)
 {
 	int rc;
-	struct channel	*ch = (struct channel *)thischan;
+	struct channel	*ch = from_tasklet(ch, t, ch_disc_tasklet);
 	unsigned long	saveflags = 0;
 
 	spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
diff --git a/drivers/s390/net/ctcm_mpc.h b/drivers/s390/net/ctcm_mpc.h
index 441d7b211f0f..80c772326178 100644
--- a/drivers/s390/net/ctcm_mpc.h
+++ b/drivers/s390/net/ctcm_mpc.h
@@ -230,10 +230,10 @@ static inline void ctcmpc_dump32(char *buf, int len)
 
 int ctcmpc_open(struct net_device *);
 void ctcm_ccw_check_rc(struct channel *, int, char *);
-void mpc_group_ready(unsigned long adev);
+void mpc_group_ready(struct tasklet_struct *t);
 void mpc_channel_action(struct channel *ch, int direction, int action);
-void mpc_action_send_discontact(unsigned long thischan);
+void mpc_action_send_discontact(struct tasklet_struct *t);
 void mpc_action_discontact(fsm_instance *fi, int event, void *arg);
-void ctcmpc_bh(unsigned long thischan);
+void ctcmpc_bh(struct tasklet_struct *t);
 #endif
 /* --- This is the END my friend --- */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] drivers: vme: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (6 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH] drivers: s390: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH] drm: i915: " Allen Pais
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/vme/bridges/vme_fake.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index 6a1bc284f297..38dd5f949cd0 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -90,13 +90,13 @@ static struct device *vme_root;
 /*
  * Calling VME bus interrupt callback if provided.
  */
-static void fake_VIRQ_tasklet(unsigned long data)
+static void fake_VIRQ_tasklet(struct tasklet_struct *t)
 {
 	struct vme_bridge *fake_bridge;
 	struct fake_driver *bridge;
 
-	fake_bridge = (struct vme_bridge *) data;
-	bridge = fake_bridge->driver_priv;
+	bridge = from_tasklet(bridge, t, int_tasklet);
+	fake_bridge = bridge->parent;
 
 	vme_irq_handler(fake_bridge, bridge->int_level, bridge->int_statid);
 }
@@ -1098,8 +1098,7 @@ static int __init fake_init(void)
 	/* Initialize wait queues & mutual exclusion flags */
 	mutex_init(&fake_device->vme_int);
 	mutex_init(&fake_bridge->irq_mtx);
-	tasklet_init(&fake_device->int_tasklet, fake_VIRQ_tasklet,
-			(unsigned long) fake_bridge);
+	tasklet_setup(&fake_device->int_tasklet, fake_VIRQ_tasklet);
 
 	strcpy(fake_bridge->name, driver_name);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] drm: i915: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (7 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH] drivers: vme: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH] firewire: ohci: " Allen Pais
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly
and remove the .data field.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/gpu/drm/i915/gt/intel_lrc.c           | 31 ++++++++++---------
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c |  8 +++--
 2 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index 24322ef08aa4..c45e42b9f239 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -3130,9 +3130,10 @@ static bool preempt_timeout(const struct intel_engine_cs *const engine)
  * Check the unread Context Status Buffers and manage the submission of new
  * contexts to the ELSP accordingly.
  */
-static void execlists_submission_tasklet(unsigned long data)
+static void execlists_submission_tasklet(struct tasklet_struct *t)
 {
-	struct intel_engine_cs * const engine = (struct intel_engine_cs *)data;
+	struct intel_engine_cs * const engine = from_tasklet(engine, t,
+						     execlists.tasklet);
 	bool timeout = preempt_timeout(engine);
 
 	process_csb(engine);
@@ -4306,9 +4307,10 @@ static void execlists_reset_rewind(struct intel_engine_cs *engine, bool stalled)
 	spin_unlock_irqrestore(&engine->active.lock, flags);
 }
 
-static void nop_submission_tasklet(unsigned long data)
+static void nop_submission_tasklet(struct tasklet_struct *t)
 {
-	struct intel_engine_cs * const engine = (struct intel_engine_cs *)data;
+	struct intel_engine_cs * const engine = from_tasklet(engine, t,
+						     execlists.tasklet);
 
 	/* The driver is wedged; don't process any more events. */
 	WRITE_ONCE(engine->execlists.queue_priority_hint, INT_MIN);
@@ -4391,7 +4393,8 @@ static void execlists_reset_cancel(struct intel_engine_cs *engine)
 	execlists->queue = RB_ROOT_CACHED;
 
 	GEM_BUG_ON(__tasklet_is_enabled(&execlists->tasklet));
-	execlists->tasklet.func = nop_submission_tasklet;
+	execlists->tasklet.func = (void (*)(unsigned long))
+				  nop_submission_tasklet;
 
 	spin_unlock_irqrestore(&engine->active.lock, flags);
 }
@@ -4986,7 +4989,8 @@ void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
 {
 	engine->submit_request = execlists_submit_request;
 	engine->schedule = i915_schedule;
-	engine->execlists.tasklet.func = execlists_submission_tasklet;
+	engine->execlists.tasklet.func = (void (*)(unsigned long))
+		execlists_submission_tasklet;
 
 	engine->reset.prepare = execlists_reset_prepare;
 	engine->reset.rewind = execlists_reset_rewind;
@@ -5113,8 +5117,7 @@ int intel_execlists_submission_setup(struct intel_engine_cs *engine)
 	struct intel_uncore *uncore = engine->uncore;
 	u32 base = engine->mmio_base;
 
-	tasklet_init(&engine->execlists.tasklet,
-		     execlists_submission_tasklet, (unsigned long)engine);
+	tasklet_setup(&engine->execlists.tasklet, execlists_submission_tasklet);
 	timer_setup(&engine->execlists.timer, execlists_timeslice, 0);
 	timer_setup(&engine->execlists.preempt, execlists_preempt, 0);
 
@@ -5509,9 +5512,10 @@ static intel_engine_mask_t virtual_submission_mask(struct virtual_engine *ve)
 	return mask;
 }
 
-static void virtual_submission_tasklet(unsigned long data)
+static void virtual_submission_tasklet(struct tasklet_struct *t)
 {
-	struct virtual_engine * const ve = (struct virtual_engine *)data;
+	struct virtual_engine *  ve = from_tasklet(ve, t,
+						   base.execlists.tasklet);
 	const int prio = READ_ONCE(ve->base.execlists.queue_priority_hint);
 	intel_engine_mask_t mask;
 	unsigned int n;
@@ -5724,9 +5728,8 @@ intel_execlists_create_virtual(struct intel_engine_cs **siblings,
 
 	INIT_LIST_HEAD(virtual_queue(ve));
 	ve->base.execlists.queue_priority_hint = INT_MIN;
-	tasklet_init(&ve->base.execlists.tasklet,
-		     virtual_submission_tasklet,
-		     (unsigned long)ve);
+	tasklet_setup(&ve->base.execlists.tasklet,
+		     virtual_submission_tasklet);
 
 	intel_context_init(&ve->context, &ve->base);
 
@@ -5748,7 +5751,7 @@ intel_execlists_create_virtual(struct intel_engine_cs **siblings,
 		 * layering if we handle cloning of the requests and
 		 * submitting a copy into each backend.
 		 */
-		if (sibling->execlists.tasklet.func !=
+		if (sibling->execlists.tasklet.func != (void (*)(unsigned long))
 		    execlists_submission_tasklet) {
 			err = -ENODEV;
 			goto err_put;
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index fdfeb4b9b0f5..3013ff54431c 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -344,9 +344,10 @@ static void __guc_dequeue(struct intel_engine_cs *engine)
 	execlists->active = execlists->inflight;
 }
 
-static void guc_submission_tasklet(unsigned long data)
+static void guc_submission_tasklet(struct tasklet_struct *t)
 {
-	struct intel_engine_cs * const engine = (struct intel_engine_cs *)data;
+	struct intel_engine_cs * const engine = from_tasklet(engine, t,
+							     execlists.tasklet);
 	struct intel_engine_execlists * const execlists = &engine->execlists;
 	struct i915_request **port, *rq;
 	unsigned long flags;
@@ -591,7 +592,8 @@ static void guc_set_default_submission(struct intel_engine_cs *engine)
 	 */
 	intel_execlists_set_default_submission(engine);
 
-	engine->execlists.tasklet.func = guc_submission_tasklet;
+	engine->execlists.tasklet.func =
+				(void (*)(unsigned long))guc_submission_tasklet;
 
 	/* do not use execlists park/unpark */
 	engine->park = engine->unpark = NULL;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] firewire: ohci: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (8 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH] drm: i915: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH 1/2] hsi: nokia-modem: " Allen Pais
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/firewire/ohci.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 7dde21b18b04..6298ff03796e 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -921,9 +921,9 @@ static void ar_recycle_buffers(struct ar_context *ctx, unsigned int end_buffer)
 	}
 }
 
-static void ar_context_tasklet(unsigned long data)
+static void ar_context_tasklet(struct tasklet_struct *t)
 {
-	struct ar_context *ctx = (struct ar_context *)data;
+	struct ar_context *ctx = from_tasklet(ctx, t, tasklet);
 	unsigned int end_buffer_index, end_buffer_offset;
 	void *p, *end;
 
@@ -977,7 +977,7 @@ static int ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci,
 
 	ctx->regs        = regs;
 	ctx->ohci        = ohci;
-	tasklet_init(&ctx->tasklet, ar_context_tasklet, (unsigned long)ctx);
+	tasklet_setup(&ctx->tasklet, ar_context_tasklet);
 
 	for (i = 0; i < AR_BUFFERS; i++) {
 		ctx->pages[i] = alloc_page(GFP_KERNEL | GFP_DMA32);
@@ -1049,9 +1049,9 @@ static struct descriptor *find_branch_descriptor(struct descriptor *d, int z)
 		return d + z - 1;
 }
 
-static void context_tasklet(unsigned long data)
+static void context_tasklet(struct tasklet_struct *t)
 {
-	struct context *ctx = (struct context *) data;
+	struct context *ctx = from_tasklet(ctx, t, tasklet);
 	struct descriptor *d, *last;
 	u32 address;
 	int z;
@@ -1145,7 +1145,7 @@ static int context_init(struct context *ctx, struct fw_ohci *ohci,
 	ctx->buffer_tail = list_entry(ctx->buffer_list.next,
 			struct descriptor_buffer, list);
 
-	tasklet_init(&ctx->tasklet, context_tasklet, (unsigned long)ctx);
+	tasklet_setup(&ctx->tasklet, context_tasklet);
 	ctx->callback = callback;
 
 	/*
@@ -1420,7 +1420,7 @@ static void at_context_flush(struct context *ctx)
 	tasklet_disable(&ctx->tasklet);
 
 	ctx->flushing = true;
-	context_tasklet((unsigned long)ctx);
+	context_tasklet(&ctx->tasklet);
 	ctx->flushing = false;
 
 	tasklet_enable(&ctx->tasklet);
@@ -3472,7 +3472,7 @@ static int ohci_flush_iso_completions(struct fw_iso_context *base)
 	tasklet_disable(&ctx->context.tasklet);
 
 	if (!test_and_set_bit_lock(0, &ctx->flushing_completions)) {
-		context_tasklet((unsigned long)&ctx->context);
+		context_tasklet(&ctx->context.tasklet);
 
 		switch (base->type) {
 		case FW_ISO_CONTEXT_TRANSMIT:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 1/2] hsi: nokia-modem: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (9 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH] firewire: ohci: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH] input: serio: " Allen Pais
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/hsi/clients/nokia-modem.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/hsi/clients/nokia-modem.c b/drivers/hsi/clients/nokia-modem.c
index cd7ebf4c2e2f..36d373f089ce 100644
--- a/drivers/hsi/clients/nokia-modem.c
+++ b/drivers/hsi/clients/nokia-modem.c
@@ -36,9 +36,10 @@ struct nokia_modem_device {
 	struct hsi_client	*cmt_speech;
 };
 
-static void do_nokia_modem_rst_ind_tasklet(unsigned long data)
+static void do_nokia_modem_rst_ind_tasklet(struct tasklet_struct *t)
 {
-	struct nokia_modem_device *modem = (struct nokia_modem_device *)data;
+	struct nokia_modem_device *modem = from_tasklet(modem, t,
+						nokia_modem_rst_ind_tasklet);
 
 	if (!modem)
 		return;
@@ -155,8 +156,8 @@ static int nokia_modem_probe(struct device *dev)
 	modem->nokia_modem_rst_ind_irq = irq;
 	pflags = irq_get_trigger_type(irq);
 
-	tasklet_init(&modem->nokia_modem_rst_ind_tasklet,
-			do_nokia_modem_rst_ind_tasklet, (unsigned long)modem);
+	tasklet_setup(&modem->nokia_modem_rst_ind_tasklet,
+			do_nokia_modem_rst_ind_tasklet);
 	err = devm_request_irq(dev, irq, nokia_modem_rst_ind_isr,
 				pflags, "modem_rst_ind", modem);
 	if (err < 0) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] input: serio: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (10 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH 1/2] hsi: nokia-modem: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH 1/2] mailbox: bcm: " Allen Pais
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/input/serio/hp_sdc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index 13eacf6ab431..91f8253ac66a 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -301,7 +301,7 @@ static irqreturn_t hp_sdc_nmisr(int irq, void *dev_id)
 
 unsigned long hp_sdc_put(void);
 
-static void hp_sdc_tasklet(unsigned long foo)
+static void hp_sdc_tasklet(struct tasklet_struct *unused)
 {
 	write_lock_irq(&hp_sdc.rtq_lock);
 
@@ -890,7 +890,7 @@ static int __init hp_sdc_init(void)
 	hp_sdc_status_in8();
 	hp_sdc_data_in8();
 
-	tasklet_init(&hp_sdc.task, hp_sdc_tasklet, 0);
+	tasklet_setup(&hp_sdc.task, hp_sdc_tasklet, 0);
 
 	/* Sync the output buffer registers, thus scheduling hp_sdc_tasklet. */
 	t_sync.actidx	= 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 1/2] mailbox: bcm: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (11 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH] input: serio: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH 1/2] memstick: jmb38x: " Allen Pais
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/mailbox/bcm-pdc-mailbox.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mailbox/bcm-pdc-mailbox.c b/drivers/mailbox/bcm-pdc-mailbox.c
index 53945ca5d785..5b375985f7b8 100644
--- a/drivers/mailbox/bcm-pdc-mailbox.c
+++ b/drivers/mailbox/bcm-pdc-mailbox.c
@@ -962,9 +962,9 @@ static irqreturn_t pdc_irq_handler(int irq, void *data)
  * a DMA receive interrupt. Reenables the receive interrupt.
  * @data: PDC state structure
  */
-static void pdc_tasklet_cb(unsigned long data)
+static void pdc_tasklet_cb(struct tasklet_struct *t)
 {
-	struct pdc_state *pdcs = (struct pdc_state *)data;
+	struct pdc_state *pdcs = from_tasklet(pdcs, t, rx_tasklet);
 
 	pdc_receive(pdcs);
 
@@ -1589,7 +1589,7 @@ static int pdc_probe(struct platform_device *pdev)
 	pdc_hw_init(pdcs);
 
 	/* Init tasklet for deferred DMA rx processing */
-	tasklet_init(&pdcs->rx_tasklet, pdc_tasklet_cb, (unsigned long)pdcs);
+	tasklet_setup(&pdcs->rx_tasklet, pdc_tasklet_cb);
 
 	err = pdc_interrupts_init(pdcs);
 	if (err)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 1/2] memstick: jmb38x: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (12 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH 1/2] mailbox: bcm: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH 1/2] misc: ibmvmc: " Allen Pais
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/memstick/host/jmb38x_ms.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
index 4a6b866b0291..2bcf5ce113bd 100644
--- a/drivers/memstick/host/jmb38x_ms.c
+++ b/drivers/memstick/host/jmb38x_ms.c
@@ -603,10 +603,10 @@ static void jmb38x_ms_abort(struct timer_list *t)
 	spin_unlock_irqrestore(&host->lock, flags);
 }
 
-static void jmb38x_ms_req_tasklet(unsigned long data)
+static void jmb38x_ms_req_tasklet(struct tasklet_struct *t)
 {
-	struct memstick_host *msh = (struct memstick_host *)data;
-	struct jmb38x_ms_host *host = memstick_priv(msh);
+	struct jmb38x_ms_host *host = from_tasklet(host, t, notify);
+	struct memstick_host *msh = host->msh;
 	unsigned long flags;
 	int rc;
 
@@ -868,7 +868,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
 	host->irq = jm->pdev->irq;
 	host->timeout_jiffies = msecs_to_jiffies(1000);
 
-	tasklet_init(&host->notify, jmb38x_ms_req_tasklet, (unsigned long)msh);
+	tasklet_setup(&host->notify, jmb38x_ms_req_tasklet);
 	msh->request = jmb38x_ms_submit_req;
 	msh->set_param = jmb38x_ms_set_param;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 1/2] misc: ibmvmc: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (13 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH 1/2] memstick: jmb38x: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH] net: atm: convert tasklets callbacks to use from_tasklet() Allen Pais
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/misc/ibmvmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c
index 2d778d0f011e..347278c1a5e4 100644
--- a/drivers/misc/ibmvmc.c
+++ b/drivers/misc/ibmvmc.c
@@ -2064,10 +2064,10 @@ static void ibmvmc_handle_crq(struct ibmvmc_crq_msg *crq,
 	}
 }
 
-static void ibmvmc_task(unsigned long data)
+static void ibmvmc_task(struct tasklet_struct *t)
 {
-	struct crq_server_adapter *adapter =
-		(struct crq_server_adapter *)data;
+	struct crq_server_adapter *adapter = from_tasklet(adapter, t,
+							  work_task);
 	struct vio_dev *vdev = to_vio_dev(adapter->dev);
 	struct ibmvmc_crq_msg *crq;
 	int done = 0;
@@ -2150,7 +2150,7 @@ static int ibmvmc_init_crq_queue(struct crq_server_adapter *adapter)
 	queue->cur = 0;
 	spin_lock_init(&queue->lock);
 
-	tasklet_init(&adapter->work_task, ibmvmc_task, (unsigned long)adapter);
+	tasklet_setup(&adapter->work_task, ibmvmc_task);
 
 	if (request_irq(vdev->irq,
 			ibmvmc_handle_event,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] net: atm: convert tasklets callbacks to use from_tasklet()
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (14 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH 1/2] misc: ibmvmc: " Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-08-17  9:16 ` [PATCH] platform: goldfish: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

Update all the callbacks of all tasklets by using
from_tasklet() and remove .data field.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 net/atm/pppoatm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c
index 579b66da1d95..3803be8470f7 100644
--- a/net/atm/pppoatm.c
+++ b/net/atm/pppoatm.c
@@ -416,7 +416,6 @@ static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, void __user *arg)
 	pvcc->chan.mtu = atmvcc->qos.txtp.max_sdu - PPP_HDRLEN -
 	    (be.encaps == e_vc ? 0 : LLC_LEN);
 	pvcc->wakeup_tasklet = tasklet_proto;
-	pvcc->wakeup_tasklet.data = (unsigned long) &pvcc->chan;
 	err = ppp_register_channel(&pvcc->chan);
 	if (err != 0) {
 		kfree(pvcc);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH] platform: goldfish: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (15 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH] net: atm: convert tasklets callbacks to use from_tasklet() Allen Pais
@ 2020-08-17  9:16 ` Allen Pais
  2020-10-18 21:50 ` [PATCH] arch: um: " Richard Weinberger
  2020-10-19  7:39 ` Anton Ivanov
  18 siblings, 0 replies; 44+ messages in thread
From: Allen Pais @ 2020-08-17  9:16 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

From: Allen Pais <allen.lkml@gmail.com>

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/platform/goldfish/goldfish_pipe.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 1ab207ec9c94..b9bead07760c 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -577,10 +577,10 @@ static struct goldfish_pipe *signalled_pipes_pop_front(
 	return pipe;
 }
 
-static void goldfish_interrupt_task(unsigned long dev_addr)
+static void goldfish_interrupt_task(struct tasklet_struct *t)
 {
 	/* Iterate over the signalled pipes and wake them one by one */
-	struct goldfish_pipe_dev *dev = (struct goldfish_pipe_dev *)dev_addr;
+	struct goldfish_pipe_dev *dev = from_tasklet(dev, t, irq_tasklet);
 	struct goldfish_pipe *pipe;
 	int wakes;
 
@@ -811,8 +811,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev,
 {
 	int err;
 
-	tasklet_init(&dev->irq_tasklet, &goldfish_interrupt_task,
-		     (unsigned long)dev);
+	tasklet_setup(&dev->irq_tasklet, &goldfish_interrupt_task);
 
 	err = devm_request_irq(&pdev->dev, dev->irq,
 			       goldfish_pipe_interrupt,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH] char: ipmi: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 ` [PATCH] char: ipmi: " Allen Pais
@ 2020-08-17 12:15   ` Corey Minyard
  2020-08-18  9:16     ` Allen
  0 siblings, 1 reply; 44+ messages in thread
From: Corey Minyard @ 2020-08-17 12:15 UTC (permalink / raw)
  To: Allen Pais
  Cc: jdike, richard, anton.ivanov, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba, keescook, linux-um, linux-kernel,
	linux-atm-general, netdev, linux-block, linux-arm-kernel,
	openipmi-developer, linux1394-devel, intel-gfx, dri-devel,
	linux-hyperv, linux-parisc, linux-input, linux-mmc, linux-ntb,
	linux-s390, linux-spi, devel, Allen Pais, Romain Perier

On Mon, Aug 17, 2020 at 02:45:57PM +0530, Allen Pais wrote:
> From: Allen Pais <allen.lkml@gmail.com>
> 
> In preparation for unconditionally passing the
> struct tasklet_struct pointer to all tasklet
> callbacks, switch to using the new tasklet_setup()
> and from_tasklet() to pass the tasklet pointer explicitly.
> 
> Signed-off-by: Romain Perier <romain.perier@gmail.com>
> Signed-off-by: Allen Pais <allen.lkml@gmail.com>

This looks good to me.

Reviewed-by: Corey Minyard <cminyard@mvista.com>

Are you planning to push this, or do you want me to take it?  If you
want me to take it, what is the urgency?

-corey

> ---
>  drivers/char/ipmi/ipmi_msghandler.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index 737c0b6b24ea..e1814b6a1225 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -39,7 +39,7 @@
>  
>  static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
>  static int ipmi_init_msghandler(void);
> -static void smi_recv_tasklet(unsigned long);
> +static void smi_recv_tasklet(struct tasklet_struct *t);
>  static void handle_new_recv_msgs(struct ipmi_smi *intf);
>  static void need_waiter(struct ipmi_smi *intf);
>  static int handle_one_recv_msg(struct ipmi_smi *intf,
> @@ -3430,9 +3430,8 @@ int ipmi_add_smi(struct module         *owner,
>  	intf->curr_seq = 0;
>  	spin_lock_init(&intf->waiting_rcv_msgs_lock);
>  	INIT_LIST_HEAD(&intf->waiting_rcv_msgs);
> -	tasklet_init(&intf->recv_tasklet,
> -		     smi_recv_tasklet,
> -		     (unsigned long) intf);
> +	tasklet_setup(&intf->recv_tasklet,
> +		     smi_recv_tasklet);
>  	atomic_set(&intf->watchdog_pretimeouts_to_deliver, 0);
>  	spin_lock_init(&intf->xmit_msgs_lock);
>  	INIT_LIST_HEAD(&intf->xmit_msgs);
> @@ -4467,10 +4466,10 @@ static void handle_new_recv_msgs(struct ipmi_smi *intf)
>  	}
>  }
>  
> -static void smi_recv_tasklet(unsigned long val)
> +static void smi_recv_tasklet(struct tasklet_struct *t)
>  {
>  	unsigned long flags = 0; /* keep us warning-free. */
> -	struct ipmi_smi *intf = (struct ipmi_smi *) val;
> +	struct ipmi_smi *intf = from_tasklet(intf, t, recv_tasklet);
>  	int run_to_completion = intf->run_to_completion;
>  	struct ipmi_smi_msg *newmsg = NULL;
>  
> @@ -4542,7 +4541,7 @@ void ipmi_smi_msg_received(struct ipmi_smi *intf,
>  		spin_unlock_irqrestore(&intf->xmit_msgs_lock, flags);
>  
>  	if (run_to_completion)
> -		smi_recv_tasklet((unsigned long) intf);
> +		smi_recv_tasklet(&intf->recv_tasklet);
>  	else
>  		tasklet_schedule(&intf->recv_tasklet);
>  }
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 ` [PATCH] block: " Allen Pais
@ 2020-08-17 13:56   ` Jens Axboe
  2020-08-17 19:29     ` Kees Cook
  0 siblings, 1 reply; 44+ messages in thread
From: Jens Axboe @ 2020-08-17 13:56 UTC (permalink / raw)
  To: Allen Pais, jdike, richard, anton.ivanov, 3chas3, stefanr,
	airlied, daniel, sre, James.Bottomley, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, ulf.hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, davem, kuba
  Cc: keescook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

On 8/17/20 2:15 AM, Allen Pais wrote:
> From: Allen Pais <allen.lkml@gmail.com>
> 
> In preparation for unconditionally passing the
> struct tasklet_struct pointer to all tasklet
> callbacks, switch to using the new tasklet_setup()
> and from_tasklet() to pass the tasklet pointer explicitly.

Who came up with the idea to add a macro 'from_tasklet' that is just
container_of? container_of in the code would be _much_ more readable,
and not leave anyone guessing wtf from_tasklet is doing.

I'd fix that up now before everything else goes in...

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-17 13:56   ` Jens Axboe
@ 2020-08-17 19:29     ` Kees Cook
  2020-08-17 19:44       ` Jens Axboe
  0 siblings, 1 reply; 44+ messages in thread
From: Kees Cook @ 2020-08-17 19:29 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Allen Pais, jdike, richard, anton.ivanov, 3chas3, stefanr,
	airlied, daniel, sre, James.Bottomley, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, ulf.hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, davem, kuba, linux-um,
	linux-kernel, linux-atm-general, netdev, linux-block,
	linux-arm-kernel, openipmi-developer, linux1394-devel, intel-gfx,
	dri-devel, linux-hyperv, linux-parisc, linux-input, linux-mmc,
	linux-ntb, linux-s390, linux-spi, devel, Allen Pais,
	Romain Perier

On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
> On 8/17/20 2:15 AM, Allen Pais wrote:
> > From: Allen Pais <allen.lkml@gmail.com>
> > 
> > In preparation for unconditionally passing the
> > struct tasklet_struct pointer to all tasklet
> > callbacks, switch to using the new tasklet_setup()
> > and from_tasklet() to pass the tasklet pointer explicitly.
> 
> Who came up with the idea to add a macro 'from_tasklet' that is just
> container_of? container_of in the code would be _much_ more readable,
> and not leave anyone guessing wtf from_tasklet is doing.
> 
> I'd fix that up now before everything else goes in...

As I mentioned in the other thread, I think this makes things much more
readable. It's the same thing that the timer_struct conversion did
(added a container_of wrapper) to avoid the ever-repeating use of
typeof(), long lines, etc.

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-17 19:29     ` Kees Cook
@ 2020-08-17 19:44       ` Jens Axboe
  2020-08-17 19:48         ` Kees Cook
  0 siblings, 1 reply; 44+ messages in thread
From: Jens Axboe @ 2020-08-17 19:44 UTC (permalink / raw)
  To: Kees Cook
  Cc: Allen Pais, jdike, richard, anton.ivanov, 3chas3, stefanr,
	airlied, daniel, sre, James.Bottomley, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, ulf.hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, davem, kuba, linux-um,
	linux-kernel, linux-atm-general, netdev, linux-block,
	linux-arm-kernel, openipmi-developer, linux1394-devel, intel-gfx,
	dri-devel, linux-hyperv, linux-parisc, linux-input, linux-mmc,
	linux-ntb, linux-s390, linux-spi, devel, Allen Pais,
	Romain Perier

On 8/17/20 12:29 PM, Kees Cook wrote:
> On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
>> On 8/17/20 2:15 AM, Allen Pais wrote:
>>> From: Allen Pais <allen.lkml@gmail.com>
>>>
>>> In preparation for unconditionally passing the
>>> struct tasklet_struct pointer to all tasklet
>>> callbacks, switch to using the new tasklet_setup()
>>> and from_tasklet() to pass the tasklet pointer explicitly.
>>
>> Who came up with the idea to add a macro 'from_tasklet' that is just
>> container_of? container_of in the code would be _much_ more readable,
>> and not leave anyone guessing wtf from_tasklet is doing.
>>
>> I'd fix that up now before everything else goes in...
> 
> As I mentioned in the other thread, I think this makes things much more
> readable. It's the same thing that the timer_struct conversion did
> (added a container_of wrapper) to avoid the ever-repeating use of
> typeof(), long lines, etc.

But then it should use a generic name, instead of each sub-system using
some random name that makes people look up exactly what it does. I'm not
huge fan of the container_of() redundancy, but adding private variants
of this doesn't seem like the best way forward. Let's have a generic
helper that does this, and use it everywhere.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-17 19:44       ` Jens Axboe
@ 2020-08-17 19:48         ` Kees Cook
  2020-08-17 20:02           ` Jens Axboe
  0 siblings, 1 reply; 44+ messages in thread
From: Kees Cook @ 2020-08-17 19:48 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Allen Pais, jdike, richard, anton.ivanov, 3chas3, stefanr,
	airlied, daniel, sre, James.Bottomley, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, ulf.hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, davem, kuba, linux-um,
	linux-kernel, linux-atm-general, netdev, linux-block,
	linux-arm-kernel, openipmi-developer, linux1394-devel, intel-gfx,
	dri-devel, linux-hyperv, linux-parisc, linux-input, linux-mmc,
	linux-ntb, linux-s390, linux-spi, devel, Allen Pais,
	Romain Perier

On Mon, Aug 17, 2020 at 12:44:34PM -0700, Jens Axboe wrote:
> On 8/17/20 12:29 PM, Kees Cook wrote:
> > On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
> >> On 8/17/20 2:15 AM, Allen Pais wrote:
> >>> From: Allen Pais <allen.lkml@gmail.com>
> >>>
> >>> In preparation for unconditionally passing the
> >>> struct tasklet_struct pointer to all tasklet
> >>> callbacks, switch to using the new tasklet_setup()
> >>> and from_tasklet() to pass the tasklet pointer explicitly.
> >>
> >> Who came up with the idea to add a macro 'from_tasklet' that is just
> >> container_of? container_of in the code would be _much_ more readable,
> >> and not leave anyone guessing wtf from_tasklet is doing.
> >>
> >> I'd fix that up now before everything else goes in...
> > 
> > As I mentioned in the other thread, I think this makes things much more
> > readable. It's the same thing that the timer_struct conversion did
> > (added a container_of wrapper) to avoid the ever-repeating use of
> > typeof(), long lines, etc.
> 
> But then it should use a generic name, instead of each sub-system using
> some random name that makes people look up exactly what it does. I'm not
> huge fan of the container_of() redundancy, but adding private variants
> of this doesn't seem like the best way forward. Let's have a generic
> helper that does this, and use it everywhere.

I'm open to suggestions, but as things stand, these kinds of treewide
changes end up getting whole-release delays because of the need to have
the API in place for everyone before patches to do the changes can be
sent to multiple maintainers, etc.

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-17 19:48         ` Kees Cook
@ 2020-08-17 20:02           ` Jens Axboe
  2020-08-18 20:00             ` James Bottomley
  0 siblings, 1 reply; 44+ messages in thread
From: Jens Axboe @ 2020-08-17 20:02 UTC (permalink / raw)
  To: Kees Cook
  Cc: Allen Pais, jdike, richard, anton.ivanov, 3chas3, stefanr,
	airlied, daniel, sre, James.Bottomley, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, ulf.hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, davem, kuba, linux-um,
	linux-kernel, linux-atm-general, netdev, linux-block,
	linux-arm-kernel, openipmi-developer, linux1394-devel, intel-gfx,
	dri-devel, linux-hyperv, linux-parisc, linux-input, linux-mmc,
	linux-ntb, linux-s390, linux-spi, devel, Allen Pais,
	Romain Perier

On 8/17/20 12:48 PM, Kees Cook wrote:
> On Mon, Aug 17, 2020 at 12:44:34PM -0700, Jens Axboe wrote:
>> On 8/17/20 12:29 PM, Kees Cook wrote:
>>> On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
>>>> On 8/17/20 2:15 AM, Allen Pais wrote:
>>>>> From: Allen Pais <allen.lkml@gmail.com>
>>>>>
>>>>> In preparation for unconditionally passing the
>>>>> struct tasklet_struct pointer to all tasklet
>>>>> callbacks, switch to using the new tasklet_setup()
>>>>> and from_tasklet() to pass the tasklet pointer explicitly.
>>>>
>>>> Who came up with the idea to add a macro 'from_tasklet' that is just
>>>> container_of? container_of in the code would be _much_ more readable,
>>>> and not leave anyone guessing wtf from_tasklet is doing.
>>>>
>>>> I'd fix that up now before everything else goes in...
>>>
>>> As I mentioned in the other thread, I think this makes things much more
>>> readable. It's the same thing that the timer_struct conversion did
>>> (added a container_of wrapper) to avoid the ever-repeating use of
>>> typeof(), long lines, etc.
>>
>> But then it should use a generic name, instead of each sub-system using
>> some random name that makes people look up exactly what it does. I'm not
>> huge fan of the container_of() redundancy, but adding private variants
>> of this doesn't seem like the best way forward. Let's have a generic
>> helper that does this, and use it everywhere.
> 
> I'm open to suggestions, but as things stand, these kinds of treewide

On naming? Implementation is just as it stands, from_tasklet() is
totally generic which is why I objected to it. from_member()? Not great
with naming... But I can see this going further and then we'll suddenly
have tons of these. It's not good for readability.

> changes end up getting whole-release delays because of the need to have
> the API in place for everyone before patches to do the changes can be
> sent to multiple maintainers, etc.

Sure, that's always true of treewide changes like that.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] char: ipmi: convert tasklets to use new tasklet_setup() API
  2020-08-17 12:15   ` Corey Minyard
@ 2020-08-18  9:16     ` Allen
  2020-08-18 11:32       ` Corey Minyard
  0 siblings, 1 reply; 44+ messages in thread
From: Allen @ 2020-08-18  9:16 UTC (permalink / raw)
  To: minyard
  Cc: Allen Pais, jdike, richard, anton.ivanov, 3chas3, axboe, stefanr,
	airlied, daniel, sre, James.Bottomley, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, Ulf Hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, David Miller, Jakub Kicinski,
	Kees Cook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Romain Perier

> >
> > Signed-off-by: Romain Perier <romain.perier@gmail.com>
> > Signed-off-by: Allen Pais <allen.lkml@gmail.com>
>
> This looks good to me.
>
> Reviewed-by: Corey Minyard <cminyard@mvista.com>
>
> Are you planning to push this, or do you want me to take it?  If you
> want me to take it, what is the urgency?

 Thanks. Well, not hurry, as long as it goes into 5.9 with all other
changes.


>
> -corey
>
> > ---
> >  drivers/char/ipmi/ipmi_msghandler.c | 13 ++++++-------
> >  1 file changed, 6 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> > index 737c0b6b24ea..e1814b6a1225 100644
> > --- a/drivers/char/ipmi/ipmi_msghandler.c
> > +++ b/drivers/char/ipmi/ipmi_msghandler.c
> > @@ -39,7 +39,7 @@
> >
> >  static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
> >  static int ipmi_init_msghandler(void);
> > -static void smi_recv_tasklet(unsigned long);
> > +static void smi_recv_tasklet(struct tasklet_struct *t);
> >  static void handle_new_recv_msgs(struct ipmi_smi *intf);
> >  static void need_waiter(struct ipmi_smi *intf);
> >  static int handle_one_recv_msg(struct ipmi_smi *intf,
> > @@ -3430,9 +3430,8 @@ int ipmi_add_smi(struct module         *owner,
> >       intf->curr_seq = 0;
> >       spin_lock_init(&intf->waiting_rcv_msgs_lock);
> >       INIT_LIST_HEAD(&intf->waiting_rcv_msgs);
> > -     tasklet_init(&intf->recv_tasklet,
> > -                  smi_recv_tasklet,
> > -                  (unsigned long) intf);
> > +     tasklet_setup(&intf->recv_tasklet,
> > +                  smi_recv_tasklet);
> >       atomic_set(&intf->watchdog_pretimeouts_to_deliver, 0);
> >       spin_lock_init(&intf->xmit_msgs_lock);
> >       INIT_LIST_HEAD(&intf->xmit_msgs);
> > @@ -4467,10 +4466,10 @@ static void handle_new_recv_msgs(struct ipmi_smi *intf)
> >       }
> >  }
> >
> > -static void smi_recv_tasklet(unsigned long val)
> > +static void smi_recv_tasklet(struct tasklet_struct *t)
> >  {
> >       unsigned long flags = 0; /* keep us warning-free. */
> > -     struct ipmi_smi *intf = (struct ipmi_smi *) val;
> > +     struct ipmi_smi *intf = from_tasklet(intf, t, recv_tasklet);
> >       int run_to_completion = intf->run_to_completion;
> >       struct ipmi_smi_msg *newmsg = NULL;
> >
> > @@ -4542,7 +4541,7 @@ void ipmi_smi_msg_received(struct ipmi_smi *intf,
> >               spin_unlock_irqrestore(&intf->xmit_msgs_lock, flags);
> >
> >       if (run_to_completion)
> > -             smi_recv_tasklet((unsigned long) intf);
> > +             smi_recv_tasklet(&intf->recv_tasklet);
> >       else
> >               tasklet_schedule(&intf->recv_tasklet);
> >  }
> > --
> > 2.17.1
> >



-- 
       - Allen

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] char: ipmi: convert tasklets to use new tasklet_setup() API
  2020-08-18  9:16     ` Allen
@ 2020-08-18 11:32       ` Corey Minyard
  0 siblings, 0 replies; 44+ messages in thread
From: Corey Minyard @ 2020-08-18 11:32 UTC (permalink / raw)
  To: Allen
  Cc: Allen Pais, jdike, richard, anton.ivanov, 3chas3, axboe, stefanr,
	airlied, daniel, sre, James.Bottomley, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, Ulf Hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, David Miller, Jakub Kicinski,
	Kees Cook, linux-um, linux-kernel, linux-atm-general, netdev,
	linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Romain Perier

On Tue, Aug 18, 2020 at 02:46:23PM +0530, Allen wrote:
> > >
> > > Signed-off-by: Romain Perier <romain.perier@gmail.com>
> > > Signed-off-by: Allen Pais <allen.lkml@gmail.com>
> >
> > This looks good to me.
> >
> > Reviewed-by: Corey Minyard <cminyard@mvista.com>
> >
> > Are you planning to push this, or do you want me to take it?  If you
> > want me to take it, what is the urgency?
> 
>  Thanks. Well, not hurry, as long as it goes into 5.9 with all other
> changes.

Ok, this is queued in my for-next branch.

-corey

> 
> 
> >
> > -corey
> >
> > > ---
> > >  drivers/char/ipmi/ipmi_msghandler.c | 13 ++++++-------
> > >  1 file changed, 6 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> > > index 737c0b6b24ea..e1814b6a1225 100644
> > > --- a/drivers/char/ipmi/ipmi_msghandler.c
> > > +++ b/drivers/char/ipmi/ipmi_msghandler.c
> > > @@ -39,7 +39,7 @@
> > >
> > >  static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
> > >  static int ipmi_init_msghandler(void);
> > > -static void smi_recv_tasklet(unsigned long);
> > > +static void smi_recv_tasklet(struct tasklet_struct *t);
> > >  static void handle_new_recv_msgs(struct ipmi_smi *intf);
> > >  static void need_waiter(struct ipmi_smi *intf);
> > >  static int handle_one_recv_msg(struct ipmi_smi *intf,
> > > @@ -3430,9 +3430,8 @@ int ipmi_add_smi(struct module         *owner,
> > >       intf->curr_seq = 0;
> > >       spin_lock_init(&intf->waiting_rcv_msgs_lock);
> > >       INIT_LIST_HEAD(&intf->waiting_rcv_msgs);
> > > -     tasklet_init(&intf->recv_tasklet,
> > > -                  smi_recv_tasklet,
> > > -                  (unsigned long) intf);
> > > +     tasklet_setup(&intf->recv_tasklet,
> > > +                  smi_recv_tasklet);
> > >       atomic_set(&intf->watchdog_pretimeouts_to_deliver, 0);
> > >       spin_lock_init(&intf->xmit_msgs_lock);
> > >       INIT_LIST_HEAD(&intf->xmit_msgs);
> > > @@ -4467,10 +4466,10 @@ static void handle_new_recv_msgs(struct ipmi_smi *intf)
> > >       }
> > >  }
> > >
> > > -static void smi_recv_tasklet(unsigned long val)
> > > +static void smi_recv_tasklet(struct tasklet_struct *t)
> > >  {
> > >       unsigned long flags = 0; /* keep us warning-free. */
> > > -     struct ipmi_smi *intf = (struct ipmi_smi *) val;
> > > +     struct ipmi_smi *intf = from_tasklet(intf, t, recv_tasklet);
> > >       int run_to_completion = intf->run_to_completion;
> > >       struct ipmi_smi_msg *newmsg = NULL;
> > >
> > > @@ -4542,7 +4541,7 @@ void ipmi_smi_msg_received(struct ipmi_smi *intf,
> > >               spin_unlock_irqrestore(&intf->xmit_msgs_lock, flags);
> > >
> > >       if (run_to_completion)
> > > -             smi_recv_tasklet((unsigned long) intf);
> > > +             smi_recv_tasklet(&intf->recv_tasklet);
> > >       else
> > >               tasklet_schedule(&intf->recv_tasklet);
> > >  }
> > > --
> > > 2.17.1
> > >
> 
> 
> 
> -- 
>        - Allen

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-17 20:02           ` Jens Axboe
@ 2020-08-18 20:00             ` James Bottomley
  2020-08-18 20:10               ` Kees Cook
  2020-08-19 13:00               ` Jens Axboe
  0 siblings, 2 replies; 44+ messages in thread
From: James Bottomley @ 2020-08-18 20:00 UTC (permalink / raw)
  To: Jens Axboe, Kees Cook
  Cc: Allen Pais, jdike, richard, anton.ivanov, 3chas3, stefanr,
	airlied, daniel, sre, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba, linux-um, linux-kernel, linux-atm-general,
	netdev, linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

On Mon, 2020-08-17 at 13:02 -0700, Jens Axboe wrote:
> On 8/17/20 12:48 PM, Kees Cook wrote:
> > On Mon, Aug 17, 2020 at 12:44:34PM -0700, Jens Axboe wrote:
> > > On 8/17/20 12:29 PM, Kees Cook wrote:
> > > > On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
> > > > > On 8/17/20 2:15 AM, Allen Pais wrote:
> > > > > > From: Allen Pais <allen.lkml@gmail.com>
> > > > > > 
> > > > > > In preparation for unconditionally passing the
> > > > > > struct tasklet_struct pointer to all tasklet
> > > > > > callbacks, switch to using the new tasklet_setup()
> > > > > > and from_tasklet() to pass the tasklet pointer explicitly.
> > > > > 
> > > > > Who came up with the idea to add a macro 'from_tasklet' that
> > > > > is just container_of? container_of in the code would be
> > > > > _much_ more readable, and not leave anyone guessing wtf
> > > > > from_tasklet is doing.
> > > > > 
> > > > > I'd fix that up now before everything else goes in...
> > > > 
> > > > As I mentioned in the other thread, I think this makes things
> > > > much more readable. It's the same thing that the timer_struct
> > > > conversion did (added a container_of wrapper) to avoid the
> > > > ever-repeating use of typeof(), long lines, etc.
> > > 
> > > But then it should use a generic name, instead of each sub-system 
> > > using some random name that makes people look up exactly what it
> > > does. I'm not huge fan of the container_of() redundancy, but
> > > adding private variants of this doesn't seem like the best way
> > > forward. Let's have a generic helper that does this, and use it
> > > everywhere.
> > 
> > I'm open to suggestions, but as things stand, these kinds of
> > treewide
> 
> On naming? Implementation is just as it stands, from_tasklet() is
> totally generic which is why I objected to it. from_member()? Not
> great with naming... But I can see this going further and then we'll
> suddenly have tons of these. It's not good for readability.

Since both threads seem to have petered out, let me suggest in
kernel.h:

#define cast_out(ptr, container, member) \
	container_of(ptr, typeof(*container), member)

It does what you want, the argument order is the same as container_of
with the only difference being you name the containing structure
instead of having to specify its type.

James


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-18 20:00             ` James Bottomley
@ 2020-08-18 20:10               ` Kees Cook
  2020-08-18 21:00                 ` James Bottomley
  2020-08-19 10:48                 ` Allen
  2020-08-19 13:00               ` Jens Axboe
  1 sibling, 2 replies; 44+ messages in thread
From: Kees Cook @ 2020-08-18 20:10 UTC (permalink / raw)
  To: James Bottomley
  Cc: Jens Axboe, Allen Pais, jdike, richard, anton.ivanov, 3chas3,
	stefanr, airlied, daniel, sre, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba, linux-um, linux-kernel, linux-atm-general,
	netdev, linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

On Tue, Aug 18, 2020 at 01:00:33PM -0700, James Bottomley wrote:
> On Mon, 2020-08-17 at 13:02 -0700, Jens Axboe wrote:
> > On 8/17/20 12:48 PM, Kees Cook wrote:
> > > On Mon, Aug 17, 2020 at 12:44:34PM -0700, Jens Axboe wrote:
> > > > On 8/17/20 12:29 PM, Kees Cook wrote:
> > > > > On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
> > > > > > On 8/17/20 2:15 AM, Allen Pais wrote:
> > > > > > > From: Allen Pais <allen.lkml@gmail.com>
> > > > > > > 
> > > > > > > In preparation for unconditionally passing the
> > > > > > > struct tasklet_struct pointer to all tasklet
> > > > > > > callbacks, switch to using the new tasklet_setup()
> > > > > > > and from_tasklet() to pass the tasklet pointer explicitly.
> > > > > > 
> > > > > > Who came up with the idea to add a macro 'from_tasklet' that
> > > > > > is just container_of? container_of in the code would be
> > > > > > _much_ more readable, and not leave anyone guessing wtf
> > > > > > from_tasklet is doing.
> > > > > > 
> > > > > > I'd fix that up now before everything else goes in...
> > > > > 
> > > > > As I mentioned in the other thread, I think this makes things
> > > > > much more readable. It's the same thing that the timer_struct
> > > > > conversion did (added a container_of wrapper) to avoid the
> > > > > ever-repeating use of typeof(), long lines, etc.
> > > > 
> > > > But then it should use a generic name, instead of each sub-system 
> > > > using some random name that makes people look up exactly what it
> > > > does. I'm not huge fan of the container_of() redundancy, but
> > > > adding private variants of this doesn't seem like the best way
> > > > forward. Let's have a generic helper that does this, and use it
> > > > everywhere.
> > > 
> > > I'm open to suggestions, but as things stand, these kinds of
> > > treewide
> > 
> > On naming? Implementation is just as it stands, from_tasklet() is
> > totally generic which is why I objected to it. from_member()? Not
> > great with naming... But I can see this going further and then we'll
> > suddenly have tons of these. It's not good for readability.
> 
> Since both threads seem to have petered out, let me suggest in
> kernel.h:
> 
> #define cast_out(ptr, container, member) \
> 	container_of(ptr, typeof(*container), member)
> 
> It does what you want, the argument order is the same as container_of
> with the only difference being you name the containing structure
> instead of having to specify its type.

I like this! Shall I send this to Linus to see if this can land in -rc2
for use going forward?

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-18 20:10               ` Kees Cook
@ 2020-08-18 21:00                 ` James Bottomley
  2020-08-19 10:48                 ` Allen
  1 sibling, 0 replies; 44+ messages in thread
From: James Bottomley @ 2020-08-18 21:00 UTC (permalink / raw)
  To: Kees Cook
  Cc: Jens Axboe, Allen Pais, jdike, richard, anton.ivanov, 3chas3,
	stefanr, airlied, daniel, sre, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba, linux-um, linux-kernel, linux-atm-general,
	netdev, linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

On Tue, 2020-08-18 at 13:10 -0700, Kees Cook wrote:
> On Tue, Aug 18, 2020 at 01:00:33PM -0700, James Bottomley wrote:
> > On Mon, 2020-08-17 at 13:02 -0700, Jens Axboe wrote:
> > > On 8/17/20 12:48 PM, Kees Cook wrote:
> > > > On Mon, Aug 17, 2020 at 12:44:34PM -0700, Jens Axboe wrote:
> > > > > On 8/17/20 12:29 PM, Kees Cook wrote:
> > > > > > On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
> > > > > > > On 8/17/20 2:15 AM, Allen Pais wrote:
> > > > > > > > From: Allen Pais <allen.lkml@gmail.com>
> > > > > > > > 
> > > > > > > > In preparation for unconditionally passing the
> > > > > > > > struct tasklet_struct pointer to all tasklet
> > > > > > > > callbacks, switch to using the new tasklet_setup()
> > > > > > > > and from_tasklet() to pass the tasklet pointer
> > > > > > > > explicitly.
> > > > > > > 
> > > > > > > Who came up with the idea to add a macro 'from_tasklet'
> > > > > > > that
> > > > > > > is just container_of? container_of in the code would be
> > > > > > > _much_ more readable, and not leave anyone guessing wtf
> > > > > > > from_tasklet is doing.
> > > > > > > 
> > > > > > > I'd fix that up now before everything else goes in...
> > > > > > 
> > > > > > As I mentioned in the other thread, I think this makes
> > > > > > things
> > > > > > much more readable. It's the same thing that the
> > > > > > timer_struct
> > > > > > conversion did (added a container_of wrapper) to avoid the
> > > > > > ever-repeating use of typeof(), long lines, etc.
> > > > > 
> > > > > But then it should use a generic name, instead of each sub-
> > > > > system 
> > > > > using some random name that makes people look up exactly what
> > > > > it
> > > > > does. I'm not huge fan of the container_of() redundancy, but
> > > > > adding private variants of this doesn't seem like the best
> > > > > way
> > > > > forward. Let's have a generic helper that does this, and use
> > > > > it
> > > > > everywhere.
> > > > 
> > > > I'm open to suggestions, but as things stand, these kinds of
> > > > treewide
> > > 
> > > On naming? Implementation is just as it stands, from_tasklet() is
> > > totally generic which is why I objected to it. from_member()? Not
> > > great with naming... But I can see this going further and then
> > > we'll
> > > suddenly have tons of these. It's not good for readability.
> > 
> > Since both threads seem to have petered out, let me suggest in
> > kernel.h:
> > 
> > #define cast_out(ptr, container, member) \
> > 	container_of(ptr, typeof(*container), member)
> > 
> > It does what you want, the argument order is the same as
> > container_of with the only difference being you name the containing
> > structure instead of having to specify its type.
> 
> I like this! Shall I send this to Linus to see if this can land in
> -rc2 for use going forward?

Sure ... he's probably been lurking on this thread anyway ... it's
about time he got off his arse^Wthe fence and made an executive
decision ...

James


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-18 20:10               ` Kees Cook
  2020-08-18 21:00                 ` James Bottomley
@ 2020-08-19 10:48                 ` Allen
  1 sibling, 0 replies; 44+ messages in thread
From: Allen @ 2020-08-19 10:48 UTC (permalink / raw)
  To: Kees Cook
  Cc: James Bottomley, Jens Axboe, Allen Pais, jdike, richard,
	anton.ivanov, 3chas3, stefanr, airlied, daniel, sre, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, Ulf Hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, David Miller, Jakub Kicinski,
	linux-um, linux-kernel, linux-atm-general, netdev, linux-block,
	linux-arm-kernel, openipmi-developer, linux1394-devel, intel-gfx,
	dri-devel, linux-hyperv, linux-parisc, linux-input, linux-mmc,
	linux-ntb, linux-s390, linux-spi, devel, Romain Perier

> > > > > > > >
> > > > > > > > In preparation for unconditionally passing the
> > > > > > > > struct tasklet_struct pointer to all tasklet
> > > > > > > > callbacks, switch to using the new tasklet_setup()
> > > > > > > > and from_tasklet() to pass the tasklet pointer explicitly.
> > > > > > >
> > > > > > > Who came up with the idea to add a macro 'from_tasklet' that
> > > > > > > is just container_of? container_of in the code would be
> > > > > > > _much_ more readable, and not leave anyone guessing wtf
> > > > > > > from_tasklet is doing.
> > > > > > >
> > > > > > > I'd fix that up now before everything else goes in...
> > > > > >
> > > > > > As I mentioned in the other thread, I think this makes things
> > > > > > much more readable. It's the same thing that the timer_struct
> > > > > > conversion did (added a container_of wrapper) to avoid the
> > > > > > ever-repeating use of typeof(), long lines, etc.
> > > > >
> > > > > But then it should use a generic name, instead of each sub-system
> > > > > using some random name that makes people look up exactly what it
> > > > > does. I'm not huge fan of the container_of() redundancy, but
> > > > > adding private variants of this doesn't seem like the best way
> > > > > forward. Let's have a generic helper that does this, and use it
> > > > > everywhere.
> > > >
> > > > I'm open to suggestions, but as things stand, these kinds of
> > > > treewide
> > >
> > > On naming? Implementation is just as it stands, from_tasklet() is
> > > totally generic which is why I objected to it. from_member()? Not
> > > great with naming... But I can see this going further and then we'll
> > > suddenly have tons of these. It's not good for readability.
> >
> > Since both threads seem to have petered out, let me suggest in
> > kernel.h:
> >
> > #define cast_out(ptr, container, member) \
> >       container_of(ptr, typeof(*container), member)
> >
> > It does what you want, the argument order is the same as container_of
> > with the only difference being you name the containing structure
> > instead of having to specify its type.
>
> I like this! Shall I send this to Linus to see if this can land in -rc2
> for use going forward?
>

Cool, I shall wait for it to be accepted and then spin out V2 with cast_out()

-- 
       - Allen

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-18 20:00             ` James Bottomley
  2020-08-18 20:10               ` Kees Cook
@ 2020-08-19 13:00               ` Jens Axboe
  2020-08-19 13:11                 ` Greg KH
  2020-08-19 14:59                 ` James Bottomley
  1 sibling, 2 replies; 44+ messages in thread
From: Jens Axboe @ 2020-08-19 13:00 UTC (permalink / raw)
  To: James Bottomley, Kees Cook
  Cc: Allen Pais, jdike, richard, anton.ivanov, 3chas3, stefanr,
	airlied, daniel, sre, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba, linux-um, linux-kernel, linux-atm-general,
	netdev, linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

On 8/18/20 1:00 PM, James Bottomley wrote:
> On Mon, 2020-08-17 at 13:02 -0700, Jens Axboe wrote:
>> On 8/17/20 12:48 PM, Kees Cook wrote:
>>> On Mon, Aug 17, 2020 at 12:44:34PM -0700, Jens Axboe wrote:
>>>> On 8/17/20 12:29 PM, Kees Cook wrote:
>>>>> On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
>>>>>> On 8/17/20 2:15 AM, Allen Pais wrote:
>>>>>>> From: Allen Pais <allen.lkml@gmail.com>
>>>>>>>
>>>>>>> In preparation for unconditionally passing the
>>>>>>> struct tasklet_struct pointer to all tasklet
>>>>>>> callbacks, switch to using the new tasklet_setup()
>>>>>>> and from_tasklet() to pass the tasklet pointer explicitly.
>>>>>>
>>>>>> Who came up with the idea to add a macro 'from_tasklet' that
>>>>>> is just container_of? container_of in the code would be
>>>>>> _much_ more readable, and not leave anyone guessing wtf
>>>>>> from_tasklet is doing.
>>>>>>
>>>>>> I'd fix that up now before everything else goes in...
>>>>>
>>>>> As I mentioned in the other thread, I think this makes things
>>>>> much more readable. It's the same thing that the timer_struct
>>>>> conversion did (added a container_of wrapper) to avoid the
>>>>> ever-repeating use of typeof(), long lines, etc.
>>>>
>>>> But then it should use a generic name, instead of each sub-system 
>>>> using some random name that makes people look up exactly what it
>>>> does. I'm not huge fan of the container_of() redundancy, but
>>>> adding private variants of this doesn't seem like the best way
>>>> forward. Let's have a generic helper that does this, and use it
>>>> everywhere.
>>>
>>> I'm open to suggestions, but as things stand, these kinds of
>>> treewide
>>
>> On naming? Implementation is just as it stands, from_tasklet() is
>> totally generic which is why I objected to it. from_member()? Not
>> great with naming... But I can see this going further and then we'll
>> suddenly have tons of these. It's not good for readability.
> 
> Since both threads seem to have petered out, let me suggest in
> kernel.h:
> 
> #define cast_out(ptr, container, member) \
> 	container_of(ptr, typeof(*container), member)
> 
> It does what you want, the argument order is the same as container_of
> with the only difference being you name the containing structure
> instead of having to specify its type.

Not to incessantly bike shed on the naming, but I don't like cast_out,
it's not very descriptive. And it has connotations of getting rid of
something, which isn't really true.

FWIW, I like the from_ part of the original naming, as it has some clues
as to what is being done here. Why not just from_container()? That
should immediately tell people what it does without having to look up
the implementation, even before this becomes a part of the accepted
coding norm.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-19 13:00               ` Jens Axboe
@ 2020-08-19 13:11                 ` Greg KH
  2020-08-19 13:17                   ` Jens Axboe
  2020-08-19 14:59                 ` James Bottomley
  1 sibling, 1 reply; 44+ messages in thread
From: Greg KH @ 2020-08-19 13:11 UTC (permalink / raw)
  To: Jens Axboe
  Cc: James Bottomley, Kees Cook, ulf.hansson, linux-atm-general,
	manohar.vanga, airlied, Allen Pais, linux-hyperv, dri-devel,
	linux-kernel, anton.ivanov, devel, linux-s390, linux1394-devel,
	maximlevitsky, richard, deller, jassisinghbrar, 3chas3,
	intel-gfx, kuba, mporter, jdike, oakad, s.hauer, linux-input,
	linux-um, linux-block, broonie, openipmi-developer, mitch,
	linux-arm-kernel, linux-parisc, netdev, martyn, dmitry.torokhov,
	linux-mmc, sre, linux-spi, alex.bou9, Allen Pais, stefanr,
	daniel, linux-ntb, Romain Perier, shawnguo, davem

On Wed, Aug 19, 2020 at 07:00:53AM -0600, Jens Axboe wrote:
> On 8/18/20 1:00 PM, James Bottomley wrote:
> > On Mon, 2020-08-17 at 13:02 -0700, Jens Axboe wrote:
> >> On 8/17/20 12:48 PM, Kees Cook wrote:
> >>> On Mon, Aug 17, 2020 at 12:44:34PM -0700, Jens Axboe wrote:
> >>>> On 8/17/20 12:29 PM, Kees Cook wrote:
> >>>>> On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
> >>>>>> On 8/17/20 2:15 AM, Allen Pais wrote:
> >>>>>>> From: Allen Pais <allen.lkml@gmail.com>
> >>>>>>>
> >>>>>>> In preparation for unconditionally passing the
> >>>>>>> struct tasklet_struct pointer to all tasklet
> >>>>>>> callbacks, switch to using the new tasklet_setup()
> >>>>>>> and from_tasklet() to pass the tasklet pointer explicitly.
> >>>>>>
> >>>>>> Who came up with the idea to add a macro 'from_tasklet' that
> >>>>>> is just container_of? container_of in the code would be
> >>>>>> _much_ more readable, and not leave anyone guessing wtf
> >>>>>> from_tasklet is doing.
> >>>>>>
> >>>>>> I'd fix that up now before everything else goes in...
> >>>>>
> >>>>> As I mentioned in the other thread, I think this makes things
> >>>>> much more readable. It's the same thing that the timer_struct
> >>>>> conversion did (added a container_of wrapper) to avoid the
> >>>>> ever-repeating use of typeof(), long lines, etc.
> >>>>
> >>>> But then it should use a generic name, instead of each sub-system 
> >>>> using some random name that makes people look up exactly what it
> >>>> does. I'm not huge fan of the container_of() redundancy, but
> >>>> adding private variants of this doesn't seem like the best way
> >>>> forward. Let's have a generic helper that does this, and use it
> >>>> everywhere.
> >>>
> >>> I'm open to suggestions, but as things stand, these kinds of
> >>> treewide
> >>
> >> On naming? Implementation is just as it stands, from_tasklet() is
> >> totally generic which is why I objected to it. from_member()? Not
> >> great with naming... But I can see this going further and then we'll
> >> suddenly have tons of these. It's not good for readability.
> > 
> > Since both threads seem to have petered out, let me suggest in
> > kernel.h:
> > 
> > #define cast_out(ptr, container, member) \
> > 	container_of(ptr, typeof(*container), member)
> > 
> > It does what you want, the argument order is the same as container_of
> > with the only difference being you name the containing structure
> > instead of having to specify its type.
> 
> Not to incessantly bike shed on the naming, but I don't like cast_out,
> it's not very descriptive. And it has connotations of getting rid of
> something, which isn't really true.

I agree, if we want to bike shed, I don't like this color either.

> FWIW, I like the from_ part of the original naming, as it has some clues
> as to what is being done here. Why not just from_container()? That
> should immediately tell people what it does without having to look up
> the implementation, even before this becomes a part of the accepted
> coding norm.

Why are people hating on the well-known and used container_of()?

If you really hate to type the type and want a new macro, what about
'container_from()'?  (noun/verb is nicer to sort symbols by...)

But really, why is this even needed?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-19 13:11                 ` Greg KH
@ 2020-08-19 13:17                   ` Jens Axboe
  2020-08-19 13:30                     ` Greg KH
  0 siblings, 1 reply; 44+ messages in thread
From: Jens Axboe @ 2020-08-19 13:17 UTC (permalink / raw)
  To: Greg KH
  Cc: James Bottomley, Kees Cook, ulf.hansson, linux-atm-general,
	manohar.vanga, airlied, Allen Pais, linux-hyperv, dri-devel,
	linux-kernel, anton.ivanov, devel, linux-s390, linux1394-devel,
	maximlevitsky, richard, deller, jassisinghbrar, 3chas3,
	intel-gfx, kuba, mporter, jdike, oakad, s.hauer, linux-input,
	linux-um, linux-block, broonie, openipmi-developer, mitch,
	linux-arm-kernel, linux-parisc, netdev, martyn, dmitry.torokhov,
	linux-mmc, sre, linux-spi, alex.bou9, Allen Pais, stefanr,
	daniel, linux-ntb, Romain Perier, shawnguo, davem

On 8/19/20 6:11 AM, Greg KH wrote:
> On Wed, Aug 19, 2020 at 07:00:53AM -0600, Jens Axboe wrote:
>> On 8/18/20 1:00 PM, James Bottomley wrote:
>>> On Mon, 2020-08-17 at 13:02 -0700, Jens Axboe wrote:
>>>> On 8/17/20 12:48 PM, Kees Cook wrote:
>>>>> On Mon, Aug 17, 2020 at 12:44:34PM -0700, Jens Axboe wrote:
>>>>>> On 8/17/20 12:29 PM, Kees Cook wrote:
>>>>>>> On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
>>>>>>>> On 8/17/20 2:15 AM, Allen Pais wrote:
>>>>>>>>> From: Allen Pais <allen.lkml@gmail.com>
>>>>>>>>>
>>>>>>>>> In preparation for unconditionally passing the
>>>>>>>>> struct tasklet_struct pointer to all tasklet
>>>>>>>>> callbacks, switch to using the new tasklet_setup()
>>>>>>>>> and from_tasklet() to pass the tasklet pointer explicitly.
>>>>>>>>
>>>>>>>> Who came up with the idea to add a macro 'from_tasklet' that
>>>>>>>> is just container_of? container_of in the code would be
>>>>>>>> _much_ more readable, and not leave anyone guessing wtf
>>>>>>>> from_tasklet is doing.
>>>>>>>>
>>>>>>>> I'd fix that up now before everything else goes in...
>>>>>>>
>>>>>>> As I mentioned in the other thread, I think this makes things
>>>>>>> much more readable. It's the same thing that the timer_struct
>>>>>>> conversion did (added a container_of wrapper) to avoid the
>>>>>>> ever-repeating use of typeof(), long lines, etc.
>>>>>>
>>>>>> But then it should use a generic name, instead of each sub-system 
>>>>>> using some random name that makes people look up exactly what it
>>>>>> does. I'm not huge fan of the container_of() redundancy, but
>>>>>> adding private variants of this doesn't seem like the best way
>>>>>> forward. Let's have a generic helper that does this, and use it
>>>>>> everywhere.
>>>>>
>>>>> I'm open to suggestions, but as things stand, these kinds of
>>>>> treewide
>>>>
>>>> On naming? Implementation is just as it stands, from_tasklet() is
>>>> totally generic which is why I objected to it. from_member()? Not
>>>> great with naming... But I can see this going further and then we'll
>>>> suddenly have tons of these. It's not good for readability.
>>>
>>> Since both threads seem to have petered out, let me suggest in
>>> kernel.h:
>>>
>>> #define cast_out(ptr, container, member) \
>>> 	container_of(ptr, typeof(*container), member)
>>>
>>> It does what you want, the argument order is the same as container_of
>>> with the only difference being you name the containing structure
>>> instead of having to specify its type.
>>
>> Not to incessantly bike shed on the naming, but I don't like cast_out,
>> it's not very descriptive. And it has connotations of getting rid of
>> something, which isn't really true.
> 
> I agree, if we want to bike shed, I don't like this color either.
> 
>> FWIW, I like the from_ part of the original naming, as it has some clues
>> as to what is being done here. Why not just from_container()? That
>> should immediately tell people what it does without having to look up
>> the implementation, even before this becomes a part of the accepted
>> coding norm.
> 
> Why are people hating on the well-known and used container_of()?
> 
> If you really hate to type the type and want a new macro, what about
> 'container_from()'?  (noun/verb is nicer to sort symbols by...)
> 
> But really, why is this even needed?

container_from() or from_container(), either works just fine for me
in terms of naming.

I think people are hating on it because it makes for _really_ long
lines, and it's arguably cleaner/simpler to just pass in the pointer
type instead. Then you end up with lines like this:

	struct request_queue *q =                                               
		container_of(work, struct request_queue, requeue_work.work);  

But I'm not the one that started this addition of from_tasklet(), my
objection was adding a private macro for something that should be
generic functionality. Hence I think we either need to provide that, or
tell the from_tasklet() folks that they should just use container_of().

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-19 13:17                   ` Jens Axboe
@ 2020-08-19 13:30                     ` Greg KH
  0 siblings, 0 replies; 44+ messages in thread
From: Greg KH @ 2020-08-19 13:30 UTC (permalink / raw)
  To: Jens Axboe
  Cc: ulf.hansson, jassisinghbrar, s.hauer, manohar.vanga, airlied,
	linux-hyperv, dri-devel, linux-kernel, James Bottomley,
	linux1394-devel, anton.ivanov, devel, linux-s390, maximlevitsky,
	richard, deller, linux-atm-general, 3chas3, linux-input, kuba,
	mporter, jdike, Kees Cook, oakad, intel-gfx, linux-um,
	linux-block, broonie, openipmi-developer, mitch,
	linux-arm-kernel, linux-parisc, netdev, martyn, dmitry.torokhov,
	linux-mmc, Allen Pais, linux-spi, alex.bou9, Allen Pais, stefanr,
	daniel, sre, linux-ntb, Romain Perier, shawnguo, davem

On Wed, Aug 19, 2020 at 07:17:19AM -0600, Jens Axboe wrote:
> On 8/19/20 6:11 AM, Greg KH wrote:
> > On Wed, Aug 19, 2020 at 07:00:53AM -0600, Jens Axboe wrote:
> >> On 8/18/20 1:00 PM, James Bottomley wrote:
> >>> On Mon, 2020-08-17 at 13:02 -0700, Jens Axboe wrote:
> >>>> On 8/17/20 12:48 PM, Kees Cook wrote:
> >>>>> On Mon, Aug 17, 2020 at 12:44:34PM -0700, Jens Axboe wrote:
> >>>>>> On 8/17/20 12:29 PM, Kees Cook wrote:
> >>>>>>> On Mon, Aug 17, 2020 at 06:56:47AM -0700, Jens Axboe wrote:
> >>>>>>>> On 8/17/20 2:15 AM, Allen Pais wrote:
> >>>>>>>>> From: Allen Pais <allen.lkml@gmail.com>
> >>>>>>>>>
> >>>>>>>>> In preparation for unconditionally passing the
> >>>>>>>>> struct tasklet_struct pointer to all tasklet
> >>>>>>>>> callbacks, switch to using the new tasklet_setup()
> >>>>>>>>> and from_tasklet() to pass the tasklet pointer explicitly.
> >>>>>>>>
> >>>>>>>> Who came up with the idea to add a macro 'from_tasklet' that
> >>>>>>>> is just container_of? container_of in the code would be
> >>>>>>>> _much_ more readable, and not leave anyone guessing wtf
> >>>>>>>> from_tasklet is doing.
> >>>>>>>>
> >>>>>>>> I'd fix that up now before everything else goes in...
> >>>>>>>
> >>>>>>> As I mentioned in the other thread, I think this makes things
> >>>>>>> much more readable. It's the same thing that the timer_struct
> >>>>>>> conversion did (added a container_of wrapper) to avoid the
> >>>>>>> ever-repeating use of typeof(), long lines, etc.
> >>>>>>
> >>>>>> But then it should use a generic name, instead of each sub-system 
> >>>>>> using some random name that makes people look up exactly what it
> >>>>>> does. I'm not huge fan of the container_of() redundancy, but
> >>>>>> adding private variants of this doesn't seem like the best way
> >>>>>> forward. Let's have a generic helper that does this, and use it
> >>>>>> everywhere.
> >>>>>
> >>>>> I'm open to suggestions, but as things stand, these kinds of
> >>>>> treewide
> >>>>
> >>>> On naming? Implementation is just as it stands, from_tasklet() is
> >>>> totally generic which is why I objected to it. from_member()? Not
> >>>> great with naming... But I can see this going further and then we'll
> >>>> suddenly have tons of these. It's not good for readability.
> >>>
> >>> Since both threads seem to have petered out, let me suggest in
> >>> kernel.h:
> >>>
> >>> #define cast_out(ptr, container, member) \
> >>> 	container_of(ptr, typeof(*container), member)
> >>>
> >>> It does what you want, the argument order is the same as container_of
> >>> with the only difference being you name the containing structure
> >>> instead of having to specify its type.
> >>
> >> Not to incessantly bike shed on the naming, but I don't like cast_out,
> >> it's not very descriptive. And it has connotations of getting rid of
> >> something, which isn't really true.
> > 
> > I agree, if we want to bike shed, I don't like this color either.
> > 
> >> FWIW, I like the from_ part of the original naming, as it has some clues
> >> as to what is being done here. Why not just from_container()? That
> >> should immediately tell people what it does without having to look up
> >> the implementation, even before this becomes a part of the accepted
> >> coding norm.
> > 
> > Why are people hating on the well-known and used container_of()?
> > 
> > If you really hate to type the type and want a new macro, what about
> > 'container_from()'?  (noun/verb is nicer to sort symbols by...)
> > 
> > But really, why is this even needed?
> 
> container_from() or from_container(), either works just fine for me
> in terms of naming.
> 
> I think people are hating on it because it makes for _really_ long
> lines, and it's arguably cleaner/simpler to just pass in the pointer
> type instead. Then you end up with lines like this:
> 
> 	struct request_queue *q =                                               
> 		container_of(work, struct request_queue, requeue_work.work);  
> 
> But I'm not the one that started this addition of from_tasklet(), my
> objection was adding a private macro for something that should be
> generic functionality.

Agreed.

> Hence I think we either need to provide that, or
> tell the from_tasklet() folks that they should just use container_of().

Also agreed, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-19 13:00               ` Jens Axboe
  2020-08-19 13:11                 ` Greg KH
@ 2020-08-19 14:59                 ` James Bottomley
  2020-08-19 16:24                   ` Allen
  1 sibling, 1 reply; 44+ messages in thread
From: James Bottomley @ 2020-08-19 14:59 UTC (permalink / raw)
  To: Jens Axboe, Kees Cook
  Cc: Allen Pais, jdike, richard, anton.ivanov, 3chas3, stefanr,
	airlied, daniel, sre, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba, linux-um, linux-kernel, linux-atm-general,
	netdev, linux-block, linux-arm-kernel, openipmi-developer,
	linux1394-devel, intel-gfx, dri-devel, linux-hyperv,
	linux-parisc, linux-input, linux-mmc, linux-ntb, linux-s390,
	linux-spi, devel, Allen Pais, Romain Perier

On Wed, 2020-08-19 at 07:00 -0600, Jens Axboe wrote:
> On 8/18/20 1:00 PM, James Bottomley wrote:
[...]
> > Since both threads seem to have petered out, let me suggest in
> > kernel.h:
> > 
> > #define cast_out(ptr, container, member) \
> > 	container_of(ptr, typeof(*container), member)
> > 
> > It does what you want, the argument order is the same as
> > container_of with the only difference being you name the containing
> > structure instead of having to specify its type.
> 
> Not to incessantly bike shed on the naming, but I don't like
> cast_out, it's not very descriptive. And it has connotations of
> getting rid of something, which isn't really true.

Um, I thought it was exactly descriptive: you're casting to the outer
container.  I thought about following the C++ dynamic casting style, so
out_cast(), but that seemed a bit pejorative.  What about outer_cast()?

> FWIW, I like the from_ part of the original naming, as it has some
> clues as to what is being done here. Why not just from_container()?
> That should immediately tell people what it does without having to
> look up the implementation, even before this becomes a part of the
> accepted coding norm.

I'm not opposed to container_from() but it seems a little less
descriptive than outer_cast() but I don't really care.  I always have
to look up container_of() when I'm using it so this would just be
another macro of that type ...

James


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-19 14:59                 ` James Bottomley
@ 2020-08-19 16:24                   ` Allen
  2020-08-19 16:56                     ` Jens Axboe
  2020-08-19 21:39                     ` James Bottomley
  0 siblings, 2 replies; 44+ messages in thread
From: Allen @ 2020-08-19 16:24 UTC (permalink / raw)
  To: James Bottomley
  Cc: Jens Axboe, Kees Cook, Allen Pais, jdike, richard, anton.ivanov,
	3chas3, stefanr, airlied, Daniel Vetter, sre, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, Ulf Hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, David Miller, Jakub Kicinski,
	linux-um, linux-kernel, linux-atm-general, netdev, linux-block,
	linux-arm-kernel, openipmi-developer, linux1394-devel, intel-gfx,
	dri-devel, linux-hyperv, linux-parisc, linux-input, linux-mmc,
	linux-ntb, linux-s390, linux-spi, devel, Romain Perier

> [...]
> > > Since both threads seem to have petered out, let me suggest in
> > > kernel.h:
> > >
> > > #define cast_out(ptr, container, member) \
> > >     container_of(ptr, typeof(*container), member)
> > >
> > > It does what you want, the argument order is the same as
> > > container_of with the only difference being you name the containing
> > > structure instead of having to specify its type.
> >
> > Not to incessantly bike shed on the naming, but I don't like
> > cast_out, it's not very descriptive. And it has connotations of
> > getting rid of something, which isn't really true.
>
> Um, I thought it was exactly descriptive: you're casting to the outer
> container.  I thought about following the C++ dynamic casting style, so
> out_cast(), but that seemed a bit pejorative.  What about outer_cast()?
>
> > FWIW, I like the from_ part of the original naming, as it has some
> > clues as to what is being done here. Why not just from_container()?
> > That should immediately tell people what it does without having to
> > look up the implementation, even before this becomes a part of the
> > accepted coding norm.
>
> I'm not opposed to container_from() but it seems a little less
> descriptive than outer_cast() but I don't really care.  I always have
> to look up container_of() when I'm using it so this would just be
> another macro of that type ...
>

 So far we have a few which have been suggested as replacement
for from_tasklet()

- out_cast() or outer_cast()
- from_member().
- container_from() or from_container()

from_container() sounds fine, would trimming it a bit work? like from_cont().

-- 
       - Allen

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-19 16:24                   ` Allen
@ 2020-08-19 16:56                     ` Jens Axboe
  2020-08-19 21:39                     ` James Bottomley
  1 sibling, 0 replies; 44+ messages in thread
From: Jens Axboe @ 2020-08-19 16:56 UTC (permalink / raw)
  To: Allen, James Bottomley
  Cc: Kees Cook, Allen Pais, jdike, richard, anton.ivanov, 3chas3,
	stefanr, airlied, Daniel Vetter, sre, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, Ulf Hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, David Miller, Jakub Kicinski,
	linux-um, linux-kernel, linux-atm-general, netdev, linux-block,
	linux-arm-kernel, openipmi-developer, linux1394-devel, intel-gfx,
	dri-devel, linux-hyperv, linux-parisc, linux-input, linux-mmc,
	linux-ntb, linux-s390, linux-spi, devel, Romain Perier

On 8/19/20 9:24 AM, Allen wrote:
>> [...]
>>>> Since both threads seem to have petered out, let me suggest in
>>>> kernel.h:
>>>>
>>>> #define cast_out(ptr, container, member) \
>>>>     container_of(ptr, typeof(*container), member)
>>>>
>>>> It does what you want, the argument order is the same as
>>>> container_of with the only difference being you name the containing
>>>> structure instead of having to specify its type.
>>>
>>> Not to incessantly bike shed on the naming, but I don't like
>>> cast_out, it's not very descriptive. And it has connotations of
>>> getting rid of something, which isn't really true.
>>
>> Um, I thought it was exactly descriptive: you're casting to the outer
>> container.  I thought about following the C++ dynamic casting style, so
>> out_cast(), but that seemed a bit pejorative.  What about outer_cast()?
>>
>>> FWIW, I like the from_ part of the original naming, as it has some
>>> clues as to what is being done here. Why not just from_container()?
>>> That should immediately tell people what it does without having to
>>> look up the implementation, even before this becomes a part of the
>>> accepted coding norm.
>>
>> I'm not opposed to container_from() but it seems a little less
>> descriptive than outer_cast() but I don't really care.  I always have
>> to look up container_of() when I'm using it so this would just be
>> another macro of that type ...
>>
> 
>  So far we have a few which have been suggested as replacement
> for from_tasklet()
> 
> - out_cast() or outer_cast()
> - from_member().
> - container_from() or from_container()
> 
> from_container() sounds fine, would trimming it a bit work? like from_cont().

I like container_from() the most, since it's the closest to contain_of()
which is a well known idiom for years. The lines will already be shorter
without the need to specify the struct, so don't like the idea of
squeezing container into cont for any of them. For most people, cont is
usually short for continue, not container.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-19 16:24                   ` Allen
  2020-08-19 16:56                     ` Jens Axboe
@ 2020-08-19 21:39                     ` James Bottomley
  2020-08-26  1:51                       ` Allen Pais
  1 sibling, 1 reply; 44+ messages in thread
From: James Bottomley @ 2020-08-19 21:39 UTC (permalink / raw)
  To: Allen
  Cc: Jens Axboe, Kees Cook, Allen Pais, jdike, richard, anton.ivanov,
	3chas3, stefanr, airlied, Daniel Vetter, sre, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, Ulf Hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, David Miller, Jakub Kicinski,
	linux-um, linux-kernel, linux-atm-general, netdev, linux-block,
	linux-arm-kernel, openipmi-developer, linux1394-devel, intel-gfx,
	dri-devel, linux-hyperv, linux-parisc, linux-input, linux-mmc,
	linux-ntb, linux-s390, linux-spi, devel, Romain Perier

On Wed, 2020-08-19 at 21:54 +0530, Allen wrote:
> > [...]
> > > > Since both threads seem to have petered out, let me suggest in
> > > > kernel.h:
> > > > 
> > > > #define cast_out(ptr, container, member) \
> > > >     container_of(ptr, typeof(*container), member)
> > > > 
> > > > It does what you want, the argument order is the same as
> > > > container_of with the only difference being you name the
> > > > containing structure instead of having to specify its type.
> > > 
> > > Not to incessantly bike shed on the naming, but I don't like
> > > cast_out, it's not very descriptive. And it has connotations of
> > > getting rid of something, which isn't really true.
> > 
> > Um, I thought it was exactly descriptive: you're casting to the
> > outer container.  I thought about following the C++ dynamic casting
> > style, so out_cast(), but that seemed a bit pejorative.  What about
> > outer_cast()?
> > 
> > > FWIW, I like the from_ part of the original naming, as it has
> > > some clues as to what is being done here. Why not just
> > > from_container()? That should immediately tell people what it
> > > does without having to look up the implementation, even before
> > > this becomes a part of the accepted coding norm.
> > 
> > I'm not opposed to container_from() but it seems a little less
> > descriptive than outer_cast() but I don't really care.  I always
> > have to look up container_of() when I'm using it so this would just
> > be another macro of that type ...
> > 
> 
>  So far we have a few which have been suggested as replacement
> for from_tasklet()
> 
> - out_cast() or outer_cast()
> - from_member().
> - container_from() or from_container()
> 
> from_container() sounds fine, would trimming it a bit work? like
> from_cont().

I'm fine with container_from().  It's the same form as container_of()
and I think we need urgent agreement to not stall everything else so
the most innocuous name is likely to get the widest acceptance.

James


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-19 21:39                     ` James Bottomley
@ 2020-08-26  1:51                       ` Allen Pais
  2020-08-26  9:55                         ` Dan Carpenter
  0 siblings, 1 reply; 44+ messages in thread
From: Allen Pais @ 2020-08-26  1:51 UTC (permalink / raw)
  To: James Bottomley
  Cc: Allen, Jens Axboe, Kees Cook, jdike, richard, anton.ivanov,
	3chas3, stefanr, airlied, Daniel Vetter, sre, kys, deller,
	dmitry.torokhov, jassisinghbrar, shawnguo, s.hauer,
	maximlevitsky, oakad, Ulf Hansson, mporter, alex.bou9, broonie,
	martyn, manohar.vanga, mitch, David Miller, Jakub Kicinski,
	linux-um, linux-kernel, linux-atm-general, netdev, linux-block,
	linux-arm-kernel, openipmi-developer, linux1394-devel, intel-gfx,
	dri-devel, linux-hyperv, linux-parisc, linux-input, linux-mmc,
	linux-ntb, linux-s390, linux-spi, devel, Romain Perier

On Thu, Aug 20, 2020 at 3:09 AM James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
>
> On Wed, 2020-08-19 at 21:54 +0530, Allen wrote:
> > > [...]
> > > > > Since both threads seem to have petered out, let me suggest in
> > > > > kernel.h:
> > > > >
> > > > > #define cast_out(ptr, container, member) \
> > > > >     container_of(ptr, typeof(*container), member)
> > > > >
> > > > > It does what you want, the argument order is the same as
> > > > > container_of with the only difference being you name the
> > > > > containing structure instead of having to specify its type.
> > > >
> > > > Not to incessantly bike shed on the naming, but I don't like
> > > > cast_out, it's not very descriptive. And it has connotations of
> > > > getting rid of something, which isn't really true.
> > >
> > > Um, I thought it was exactly descriptive: you're casting to the
> > > outer container.  I thought about following the C++ dynamic casting
> > > style, so out_cast(), but that seemed a bit pejorative.  What about
> > > outer_cast()?
> > >
> > > > FWIW, I like the from_ part of the original naming, as it has
> > > > some clues as to what is being done here. Why not just
> > > > from_container()? That should immediately tell people what it
> > > > does without having to look up the implementation, even before
> > > > this becomes a part of the accepted coding norm.
> > >
> > > I'm not opposed to container_from() but it seems a little less
> > > descriptive than outer_cast() but I don't really care.  I always
> > > have to look up container_of() when I'm using it so this would just
> > > be another macro of that type ...
> > >
> >
> >  So far we have a few which have been suggested as replacement
> > for from_tasklet()
> >
> > - out_cast() or outer_cast()
> > - from_member().
> > - container_from() or from_container()
> >
> > from_container() sounds fine, would trimming it a bit work? like
> > from_cont().
>
> I'm fine with container_from().  It's the same form as container_of()
> and I think we need urgent agreement to not stall everything else so
> the most innocuous name is likely to get the widest acceptance.

Kees,

  Will you be  sending the newly proposed API to Linus? I have V2
which uses container_from()
ready to be sent out.

Thanks.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-26  1:51                       ` Allen Pais
@ 2020-08-26  9:55                         ` Dan Carpenter
  2020-08-26 15:13                           ` Kees Cook
  0 siblings, 1 reply; 44+ messages in thread
From: Dan Carpenter @ 2020-08-26  9:55 UTC (permalink / raw)
  To: Allen Pais
  Cc: James Bottomley, Ulf Hansson, linux-atm-general, manohar.vanga,
	airlied, linux-hyperv, dri-devel, sre, anton.ivanov, devel,
	linux-s390, linux1394-devel, maximlevitsky, richard, deller,
	jassisinghbrar, linux-spi, 3chas3, intel-gfx, Jakub Kicinski,
	mporter, jdike, Kees Cook, oakad, s.hauer, linux-input, linux-um,
	linux-block, broonie, openipmi-developer, mitch,
	linux-arm-kernel, Jens Axboe, linux-parisc, netdev, martyn,
	dmitry.torokhov, linux-mmc, Allen, linux-kernel, alex.bou9,
	stefanr, Daniel Vetter, linux-ntb, Romain Perier, shawnguo,
	David Miller

On Wed, Aug 26, 2020 at 07:21:35AM +0530, Allen Pais wrote:
> On Thu, Aug 20, 2020 at 3:09 AM James Bottomley
> <James.Bottomley@hansenpartnership.com> wrote:
> >
> > On Wed, 2020-08-19 at 21:54 +0530, Allen wrote:
> > > > [...]
> > > > > > Since both threads seem to have petered out, let me suggest in
> > > > > > kernel.h:
> > > > > >
> > > > > > #define cast_out(ptr, container, member) \
> > > > > >     container_of(ptr, typeof(*container), member)
> > > > > >
> > > > > > It does what you want, the argument order is the same as
> > > > > > container_of with the only difference being you name the
> > > > > > containing structure instead of having to specify its type.
> > > > >
> > > > > Not to incessantly bike shed on the naming, but I don't like
> > > > > cast_out, it's not very descriptive. And it has connotations of
> > > > > getting rid of something, which isn't really true.
> > > >
> > > > Um, I thought it was exactly descriptive: you're casting to the
> > > > outer container.  I thought about following the C++ dynamic casting
> > > > style, so out_cast(), but that seemed a bit pejorative.  What about
> > > > outer_cast()?
> > > >
> > > > > FWIW, I like the from_ part of the original naming, as it has
> > > > > some clues as to what is being done here. Why not just
> > > > > from_container()? That should immediately tell people what it
> > > > > does without having to look up the implementation, even before
> > > > > this becomes a part of the accepted coding norm.
> > > >
> > > > I'm not opposed to container_from() but it seems a little less
> > > > descriptive than outer_cast() but I don't really care.  I always
> > > > have to look up container_of() when I'm using it so this would just
> > > > be another macro of that type ...
> > > >
> > >
> > >  So far we have a few which have been suggested as replacement
> > > for from_tasklet()
> > >
> > > - out_cast() or outer_cast()
> > > - from_member().
> > > - container_from() or from_container()
> > >
> > > from_container() sounds fine, would trimming it a bit work? like
> > > from_cont().
> >
> > I'm fine with container_from().  It's the same form as container_of()
> > and I think we need urgent agreement to not stall everything else so
> > the most innocuous name is likely to get the widest acceptance.
> 
> Kees,
> 
>   Will you be  sending the newly proposed API to Linus? I have V2
> which uses container_from()
> ready to be sent out.

I liked that James swapped the first two arguments so that it matches
container_of().  Plus it's nice that when you have:

	struct whatever *foo = container_from(ptr, foo, member);

Then it means that "ptr == &foo->member".

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-26  9:55                         ` Dan Carpenter
@ 2020-08-26 15:13                           ` Kees Cook
  2020-08-27  1:37                             ` Allen
  0 siblings, 1 reply; 44+ messages in thread
From: Kees Cook @ 2020-08-26 15:13 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Allen Pais, James Bottomley, Ulf Hansson, linux-atm-general,
	manohar.vanga, airlied, linux-hyperv, dri-devel, sre,
	anton.ivanov, devel, linux-s390, linux1394-devel, maximlevitsky,
	richard, deller, jassisinghbrar, linux-spi, 3chas3, intel-gfx,
	Jakub Kicinski, mporter, jdike, oakad, s.hauer, linux-input,
	linux-um, linux-block, broonie, openipmi-developer, mitch,
	linux-arm-kernel, Jens Axboe, linux-parisc, netdev, martyn,
	dmitry.torokhov, linux-mmc, Allen, linux-kernel, alex.bou9,
	stefanr, Daniel Vetter, linux-ntb, Romain Perier, shawnguo,
	David Miller

On Wed, Aug 26, 2020 at 12:55:28PM +0300, Dan Carpenter wrote:
> On Wed, Aug 26, 2020 at 07:21:35AM +0530, Allen Pais wrote:
> > On Thu, Aug 20, 2020 at 3:09 AM James Bottomley
> > <James.Bottomley@hansenpartnership.com> wrote:
> > >
> > > On Wed, 2020-08-19 at 21:54 +0530, Allen wrote:
> > > > > [...]
> > > > > > > Since both threads seem to have petered out, let me suggest in
> > > > > > > kernel.h:
> > > > > > >
> > > > > > > #define cast_out(ptr, container, member) \
> > > > > > >     container_of(ptr, typeof(*container), member)
> > > > > > >
> > > > > > > It does what you want, the argument order is the same as
> > > > > > > container_of with the only difference being you name the
> > > > > > > containing structure instead of having to specify its type.
> > > > > >
> > > > > > Not to incessantly bike shed on the naming, but I don't like
> > > > > > cast_out, it's not very descriptive. And it has connotations of
> > > > > > getting rid of something, which isn't really true.
> > > > >
> > > > > Um, I thought it was exactly descriptive: you're casting to the
> > > > > outer container.  I thought about following the C++ dynamic casting
> > > > > style, so out_cast(), but that seemed a bit pejorative.  What about
> > > > > outer_cast()?
> > > > >
> > > > > > FWIW, I like the from_ part of the original naming, as it has
> > > > > > some clues as to what is being done here. Why not just
> > > > > > from_container()? That should immediately tell people what it
> > > > > > does without having to look up the implementation, even before
> > > > > > this becomes a part of the accepted coding norm.
> > > > >
> > > > > I'm not opposed to container_from() but it seems a little less
> > > > > descriptive than outer_cast() but I don't really care.  I always
> > > > > have to look up container_of() when I'm using it so this would just
> > > > > be another macro of that type ...
> > > > >
> > > >
> > > >  So far we have a few which have been suggested as replacement
> > > > for from_tasklet()
> > > >
> > > > - out_cast() or outer_cast()
> > > > - from_member().
> > > > - container_from() or from_container()
> > > >
> > > > from_container() sounds fine, would trimming it a bit work? like
> > > > from_cont().
> > >
> > > I'm fine with container_from().  It's the same form as container_of()
> > > and I think we need urgent agreement to not stall everything else so
> > > the most innocuous name is likely to get the widest acceptance.
> > 
> > Kees,
> > 
> >   Will you be  sending the newly proposed API to Linus? I have V2
> > which uses container_from()
> > ready to be sent out.
> 
> I liked that James swapped the first two arguments so that it matches
> container_of().  Plus it's nice that when you have:
> 
> 	struct whatever *foo = container_from(ptr, foo, member);
> 
> Then it means that "ptr == &foo->member".

I'm a bit stalled right now -- the merge window was keeping me busy, and
this week is the Linux Plumbers Conference. This is on my list, but I
haven't gotten back around to it. If you want, feel free to send the
container_from() patch; you might be able to unblock this faster than me
right now. :)

-Kees

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] block: convert tasklets to use new tasklet_setup() API
  2020-08-26 15:13                           ` Kees Cook
@ 2020-08-27  1:37                             ` Allen
  0 siblings, 0 replies; 44+ messages in thread
From: Allen @ 2020-08-27  1:37 UTC (permalink / raw)
  To: Kees Cook
  Cc: Dan Carpenter, Allen Pais, James Bottomley, Ulf Hansson,
	linux-atm-general, manohar.vanga, airlied, linux-hyperv,
	dri-devel, sre, anton.ivanov, devel, linux-s390, linux1394-devel,
	maximlevitsky, richard, deller, jassisinghbrar, linux-spi,
	3chas3, intel-gfx, Jakub Kicinski, mporter, jdike, oakad,
	s.hauer, linux-input, linux-um, linux-block, Mark Brown,
	openipmi-developer, mitch, linux-arm-kernel, Jens Axboe,
	linux-parisc, netdev, martyn, dmitry.torokhov, linux-mmc,
	linux-kernel, alex.bou9, stefanr, Daniel Vetter, linux-ntb,
	Romain Perier, shawnguo, David Miller

On Wed, Aug 26, 2020 at 8:43 PM Kees Cook <keescook@chromium.org> wrote:
>
> On Wed, Aug 26, 2020 at 12:55:28PM +0300, Dan Carpenter wrote:
> > On Wed, Aug 26, 2020 at 07:21:35AM +0530, Allen Pais wrote:
> > > On Thu, Aug 20, 2020 at 3:09 AM James Bottomley
> > > <James.Bottomley@hansenpartnership.com> wrote:
> > > >
> > > > On Wed, 2020-08-19 at 21:54 +0530, Allen wrote:
> > > > > > [...]
> > > > > > > > Since both threads seem to have petered out, let me suggest in
> > > > > > > > kernel.h:
> > > > > > > >
> > > > > > > > #define cast_out(ptr, container, member) \
> > > > > > > >     container_of(ptr, typeof(*container), member)
> > > > > > > >
> > > > > > > > It does what you want, the argument order is the same as
> > > > > > > > container_of with the only difference being you name the
> > > > > > > > containing structure instead of having to specify its type.
> > > > > > >
> > > > > > > Not to incessantly bike shed on the naming, but I don't like
> > > > > > > cast_out, it's not very descriptive. And it has connotations of
> > > > > > > getting rid of something, which isn't really true.
> > > > > >
> > > > > > Um, I thought it was exactly descriptive: you're casting to the
> > > > > > outer container.  I thought about following the C++ dynamic casting
> > > > > > style, so out_cast(), but that seemed a bit pejorative.  What about
> > > > > > outer_cast()?
> > > > > >
> > > > > > > FWIW, I like the from_ part of the original naming, as it has
> > > > > > > some clues as to what is being done here. Why not just
> > > > > > > from_container()? That should immediately tell people what it
> > > > > > > does without having to look up the implementation, even before
> > > > > > > this becomes a part of the accepted coding norm.
> > > > > >
> > > > > > I'm not opposed to container_from() but it seems a little less
> > > > > > descriptive than outer_cast() but I don't really care.  I always
> > > > > > have to look up container_of() when I'm using it so this would just
> > > > > > be another macro of that type ...
> > > > > >
> > > > >
> > > > >  So far we have a few which have been suggested as replacement
> > > > > for from_tasklet()
> > > > >
> > > > > - out_cast() or outer_cast()
> > > > > - from_member().
> > > > > - container_from() or from_container()
> > > > >
> > > > > from_container() sounds fine, would trimming it a bit work? like
> > > > > from_cont().
> > > >
> > > > I'm fine with container_from().  It's the same form as container_of()
> > > > and I think we need urgent agreement to not stall everything else so
> > > > the most innocuous name is likely to get the widest acceptance.
> > >
> > > Kees,
> > >
> > >   Will you be  sending the newly proposed API to Linus? I have V2
> > > which uses container_from()
> > > ready to be sent out.
> >
> > I liked that James swapped the first two arguments so that it matches
> > container_of().  Plus it's nice that when you have:
> >
> >       struct whatever *foo = container_from(ptr, foo, member);
> >
> > Then it means that "ptr == &foo->member".
>
> I'm a bit stalled right now -- the merge window was keeping me busy, and
> this week is the Linux Plumbers Conference. This is on my list, but I
> haven't gotten back around to it. If you want, feel free to send the
> container_from() patch; you might be able to unblock this faster than me
> right now. :)
>

Sure, Thanks.



-- 
       - Allen

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] arch: um: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (16 preceding siblings ...)
  2020-08-17  9:16 ` [PATCH] platform: goldfish: convert tasklets to use new tasklet_setup() API Allen Pais
@ 2020-10-18 21:50 ` Richard Weinberger
  2020-10-19  7:39 ` Anton Ivanov
  18 siblings, 0 replies; 44+ messages in thread
From: Richard Weinberger @ 2020-10-18 21:50 UTC (permalink / raw)
  To: Allen Pais
  Cc: Jeff Dike, Richard Weinberger, Anton Ivanov, 3chas3, Jens Axboe,
	stefanr, Dave Airlie, Daniel Vetter, Sebastian Reichel,
	James Bottomley, K. Y. Srinivasan, Helge Deller, dmitry.torokhov,
	jassisinghbrar, Shawn Guo, Sascha Hauer, Maxim Levitsky,
	Alex Dubov, Ulf Hansson, mporter, alex.bou9, Mark Brown, martyn,
	manohar.vanga, mitch, David S. Miller, kuba, Kees Cook, linux-um,
	LKML, linux-atm-general, netdev, linux-block, linux-arm-kernel,
	openipmi-developer, linux1394-devel, intel-gfx, DRI mailing list,
	linux-hyperv, linux-parisc, linux-input, linux-mmc, linux-ntb,
	linux-s390, open list:SPI SUBSYSTEM, devel, Allen Pais,
	Romain Perier

On Mon, Aug 17, 2020 at 11:17 AM Allen Pais <allen.cryptic@gmail.com> wrote:
>
> From: Allen Pais <allen.lkml@gmail.com>
>
> In preparation for unconditionally passing the
> struct tasklet_struct pointer to all tasklet
> callbacks, switch to using the new tasklet_setup()
> and from_tasklet() to pass the tasklet pointer explicitly.
>
> Signed-off-by: Romain Perier <romain.perier@gmail.com>
> Signed-off-by: Allen Pais <allen.lkml@gmail.com>
> ---
>  arch/um/drivers/vector_kern.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Anton, can you please review this patch?

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH] arch: um: convert tasklets to use new tasklet_setup() API
  2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
                   ` (17 preceding siblings ...)
  2020-10-18 21:50 ` [PATCH] arch: um: " Richard Weinberger
@ 2020-10-19  7:39 ` Anton Ivanov
  18 siblings, 0 replies; 44+ messages in thread
From: Anton Ivanov @ 2020-10-19  7:39 UTC (permalink / raw)
  To: Allen Pais, jdike, richard, 3chas3, axboe, stefanr, airlied,
	daniel, sre, James.Bottomley, kys, deller, dmitry.torokhov,
	jassisinghbrar, shawnguo, s.hauer, maximlevitsky, oakad,
	ulf.hansson, mporter, alex.bou9, broonie, martyn, manohar.vanga,
	mitch, davem, kuba
  Cc: devel, linux-s390, linux-hyperv, Romain Perier, keescook,
	linux-parisc, linux-ntb, netdev, intel-gfx, linux-atm-general,
	linux-um, linux-kernel, dri-devel, linux-spi, linux-block,
	Allen Pais, linux-input, linux-mmc, openipmi-developer,
	linux1394-devel, linux-arm-kernel



On 17/08/2020 10:15, Allen Pais wrote:
> From: Allen Pais <allen.lkml@gmail.com>
> 
> In preparation for unconditionally passing the
> struct tasklet_struct pointer to all tasklet
> callbacks, switch to using the new tasklet_setup()
> and from_tasklet() to pass the tasklet pointer explicitly.
> 
> Signed-off-by: Romain Perier <romain.perier@gmail.com>
> Signed-off-by: Allen Pais <allen.lkml@gmail.com>
> ---
>   arch/um/drivers/vector_kern.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 8735c468230a..06980870ae23 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -1196,9 +1196,9 @@ static int vector_net_close(struct net_device *dev)
>   
>   /* TX tasklet */
>   
> -static void vector_tx_poll(unsigned long data)
> +static void vector_tx_poll(struct tasklet_struct *t)
>   {
> -	struct vector_private *vp = (struct vector_private *)data;
> +	struct vector_private *vp = from_tasklet(vp, t, tx_poll);
>   
>   	vp->estats.tx_kicks++;
>   	vector_send(vp->tx_queue);
> @@ -1629,7 +1629,7 @@ static void vector_eth_configure(
>   	});
>   
>   	dev->features = dev->hw_features = (NETIF_F_SG | NETIF_F_FRAGLIST);
> -	tasklet_init(&vp->tx_poll, vector_tx_poll, (unsigned long)vp);
> +	tasklet_setup(&vp->tx_poll, vector_tx_poll);
>   	INIT_WORK(&vp->reset_tx, vector_reset_tx);
>   
>   	timer_setup(&vp->tl, vector_timer_expire, 0);
> 

Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2020-10-19  8:04 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17  9:15 [PATCH] arch: um: convert tasklets to use new tasklet_setup() API Allen Pais
2020-08-17  9:15 ` [PATCH] block: " Allen Pais
2020-08-17 13:56   ` Jens Axboe
2020-08-17 19:29     ` Kees Cook
2020-08-17 19:44       ` Jens Axboe
2020-08-17 19:48         ` Kees Cook
2020-08-17 20:02           ` Jens Axboe
2020-08-18 20:00             ` James Bottomley
2020-08-18 20:10               ` Kees Cook
2020-08-18 21:00                 ` James Bottomley
2020-08-19 10:48                 ` Allen
2020-08-19 13:00               ` Jens Axboe
2020-08-19 13:11                 ` Greg KH
2020-08-19 13:17                   ` Jens Axboe
2020-08-19 13:30                     ` Greg KH
2020-08-19 14:59                 ` James Bottomley
2020-08-19 16:24                   ` Allen
2020-08-19 16:56                     ` Jens Axboe
2020-08-19 21:39                     ` James Bottomley
2020-08-26  1:51                       ` Allen Pais
2020-08-26  9:55                         ` Dan Carpenter
2020-08-26 15:13                           ` Kees Cook
2020-08-27  1:37                             ` Allen
2020-08-17  9:15 ` [PATCH] char: ipmi: " Allen Pais
2020-08-17 12:15   ` Corey Minyard
2020-08-18  9:16     ` Allen
2020-08-18 11:32       ` Corey Minyard
2020-08-17  9:15 ` [PATCH] driver: hv: " Allen Pais
2020-08-17  9:15 ` [PATCH] drivers: atm: " Allen Pais
2020-08-17  9:16 ` [PATCH] drivers: ntb: " Allen Pais
2020-08-17  9:16 ` [PATCH] drivers: rapidio: " Allen Pais
2020-08-17  9:16 ` [PATCH] drivers: s390: " Allen Pais
2020-08-17  9:16 ` [PATCH] drivers: vme: " Allen Pais
2020-08-17  9:16 ` [PATCH] drm: i915: " Allen Pais
2020-08-17  9:16 ` [PATCH] firewire: ohci: " Allen Pais
2020-08-17  9:16 ` [PATCH 1/2] hsi: nokia-modem: " Allen Pais
2020-08-17  9:16 ` [PATCH] input: serio: " Allen Pais
2020-08-17  9:16 ` [PATCH 1/2] mailbox: bcm: " Allen Pais
2020-08-17  9:16 ` [PATCH 1/2] memstick: jmb38x: " Allen Pais
2020-08-17  9:16 ` [PATCH 1/2] misc: ibmvmc: " Allen Pais
2020-08-17  9:16 ` [PATCH] net: atm: convert tasklets callbacks to use from_tasklet() Allen Pais
2020-08-17  9:16 ` [PATCH] platform: goldfish: convert tasklets to use new tasklet_setup() API Allen Pais
2020-10-18 21:50 ` [PATCH] arch: um: " Richard Weinberger
2020-10-19  7:39 ` Anton Ivanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).