RE: [PATCH] kernfs: fix dentry unexpected skip

2018-05-20 Thread Hatayama, Daisuke


> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org
> [mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Hatayama, Daisuke
> Sent: Saturday, May 19, 2018 12:43 AM
> To: 'gre...@linuxfoundation.org' 
> Cc: Okajima, Toshiyuki/岡嶋 寿行 ;
> linux-kernel@vger.kernel.org; 'ebied...@aristanetworks.com'
> 
> Subject: [PATCH] kernfs: fix dentry unexpected skip
> 
> kernfs_dir_next_pos() overlooks the situation that the dentry
> corresponding to a given pos object has already been inactive. Hence,
> when kernfs_dir_pos() returns the dentry with a hash value larger than
> the original one, kernfs_dir_next_pos() returns the dentry next to the
> one returned by kernfs_dir_pos(). As a result, the dentry returned by
> kernfs_dir_pos() is skipped.
> 
> To fix this issue, try to find a next node only when the returned
> object has a hash value equal to or smaller than the original one.
> 
> Signed-off-by: HATAYAMA Daisuke 
> Suggested-by: Toshiyuki Okajima 
> Cc: Eric W. Biederman 
> ---
>  fs/kernfs/dir.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index 89d1dc1..8a2f49c 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -1622,7 +1622,7 @@ static int kernfs_dir_fop_release(struct inode *inode,
> struct file *filp)
>   struct kernfs_node *parent, ino_t ino, struct kernfs_node *pos)
>  {
>   pos = kernfs_dir_pos(ns, parent, ino, pos);
> - if (pos) {
> + if (pos && pos->hash <= ino) {

I found this condition still misses the case that the returend pos with
the same hash value but with different name is skipped. I'll post
v2 patch.

>   do {
>   struct rb_node *node = rb_next(>rb);
>   if (!node)
> --
> 1.7.1
> 
> 
> 




RE: [PATCH] kernfs: fix dentry unexpected skip

2018-05-20 Thread Hatayama, Daisuke


> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org
> [mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Hatayama, Daisuke
> Sent: Saturday, May 19, 2018 12:43 AM
> To: 'gre...@linuxfoundation.org' 
> Cc: Okajima, Toshiyuki/岡嶋 寿行 ;
> linux-kernel@vger.kernel.org; 'ebied...@aristanetworks.com'
> 
> Subject: [PATCH] kernfs: fix dentry unexpected skip
> 
> kernfs_dir_next_pos() overlooks the situation that the dentry
> corresponding to a given pos object has already been inactive. Hence,
> when kernfs_dir_pos() returns the dentry with a hash value larger than
> the original one, kernfs_dir_next_pos() returns the dentry next to the
> one returned by kernfs_dir_pos(). As a result, the dentry returned by
> kernfs_dir_pos() is skipped.
> 
> To fix this issue, try to find a next node only when the returned
> object has a hash value equal to or smaller than the original one.
> 
> Signed-off-by: HATAYAMA Daisuke 
> Suggested-by: Toshiyuki Okajima 
> Cc: Eric W. Biederman 
> ---
>  fs/kernfs/dir.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index 89d1dc1..8a2f49c 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -1622,7 +1622,7 @@ static int kernfs_dir_fop_release(struct inode *inode,
> struct file *filp)
>   struct kernfs_node *parent, ino_t ino, struct kernfs_node *pos)
>  {
>   pos = kernfs_dir_pos(ns, parent, ino, pos);
> - if (pos) {
> + if (pos && pos->hash <= ino) {

I found this condition still misses the case that the returend pos with
the same hash value but with different name is skipped. I'll post
v2 patch.

>   do {
>   struct rb_node *node = rb_next(>rb);
>   if (!node)
> --
> 1.7.1
> 
> 
> 




Re: [PATCH v3 1/4] rcu: Add comment documenting how rcu_seq_snap works

2018-05-20 Thread Joel Fernandes
On Sun, May 20, 2018 at 09:50:25PM -0700, Randy Dunlap wrote:
> On 05/20/2018 09:42 PM, Joel Fernandes wrote:
> > rcu_seq_snap may be tricky to decipher. Lets document how it works with
> > an example to make it easier.
> > 
> > Signed-off-by: Joel Fernandes (Google) 
> > ---
> >  kernel/rcu/rcu.h | 33 -
> >  1 file changed, 32 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
> > index 0453a7d12b3f..d4396c96f614 100644
> > --- a/kernel/rcu/rcu.h
> > +++ b/kernel/rcu/rcu.h
> > @@ -91,7 +91,38 @@ static inline void rcu_seq_end(unsigned long *sp)
> > WRITE_ONCE(*sp, rcu_seq_endval(sp));
> >  }
> >  
> > -/* Take a snapshot of the update side's sequence number. */
> > +/*
> > + * rcu_seq_snap - Take a snapshot of the update side's sequence number.
> > + *
> > + * This function returns the earliest value of the grace-period sequence 
> > number
> > + * that will indicate that a full grace period has elapsed since the 
> > current
> > + * time.  Once the grace-period sequence number has reached this value, it 
> > will
> > + * be safe to invoke all callbacks that have been registered prior to the
> > + * current time. This value is the current grace-period number plus two to 
> > the
> > + * power of the number of low-order bits reserved for state, then rounded 
> > up to
> > + * the next value in which the state bits are all zero.
> > + *
> > + * For example, since RCU_SEQ_STATE_MASK=3 and the least significant bit of
> > + * the seq is used to track if a GP is in progress or not, its sufficient 
> > if we
> 
>   it's
> 
> > + * add (6+1) and mask with ~3 to get the next GP. Let's see why with an 
> > example:
> > + *
> > + * Say the current seq is 12 which is 0b1100 (GP is 3 and state bits are 
> > 0b00).
> > + * To get to the next GP number of 4, we have to add 0b100 to this (0x1 << 
> > 2)
> > + * to account for the shift due to 2 state bits. Now, if the current seq is
> > + * 13 (GP is 3 and state bits are 0b01), then it means the current grace 
> > period
> > + * is already in progress so the next GP that a future call back will be 
> > queued
> > + * to run at is GP+2 = 5, not 4. To account for the extra +1, we just 
> > overflow
> > + * the 2 lower bits by adding 0b11. Incase the lower bit was set, the 
> > overflow
> 
>In case
> 
> > + * will cause the extra +1 to the GP, along with the usual +1 explained 
> > before.
> > + * This gives us GP+2. Finally we mask the lower to bits by ~0x3 incase the
> 
> in case
> 
> > + * overflow didn't occur. This masking is needed because incase RCU was 
> > idle
> 
> in case
> 
> > + * (no GP in progress so lower 2 bits are 0b00), then the overflow of the 
> > lower
> > + * 2 state bits wouldn't occur, so we mask to zero out those lower 2 bits.
> > + *
> > + * In other words, the next seq can be obtained by (0b11 + 0b100) & (~0b11)
> > + * which can be generalized to:
> > + * seq + (RCU_SEQ_STATE_MASK + (RCU_SEQ_STATE_MASK + 1)) & 
> > (~RCU_SEQ_STATE_MASK)
> > + */
> >  static inline unsigned long rcu_seq_snap(unsigned long *sp)
> >  {
> > unsigned long s;
> > 
> 
> cheers.
> -- 
> ~Randy

Thanks Randy. Fixed, updated patch below. Paul, let me know if you want
me to send it separately or if you can pick it up from below.

Also I realize I need some better automated tools to catch these issues
(spelling errors in commit, diffs etc). Probably checkpatch.pl should
have such checks for these common things too.

--8<--

>From 1c1f8ce04bca656a3c07e555048545d4a59e44cf Mon Sep 17 00:00:00 2001
From: Joel Fernandes 
Date: Sun, 20 May 2018 19:37:18 -0700
Subject: [PATCH v3.5] rcu: Add comment documenting how rcu_seq_snap works

rcu_seq_snap may be tricky to decipher. Lets document how it works with
an example to make it easier.

Signed-off-by: Joel Fernandes (Google) 
---
 kernel/rcu/rcu.h | 33 -
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index 0453a7d12b3f..00df3da98317 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -91,7 +91,38 @@ static inline void rcu_seq_end(unsigned long *sp)
WRITE_ONCE(*sp, rcu_seq_endval(sp));
 }
 
-/* Take a snapshot of the update side's sequence number. */
+/*
+ * rcu_seq_snap - Take a snapshot of the update side's sequence number.
+ *
+ * This function returns the earliest value of the grace-period sequence number
+ * that will indicate that a full grace period has elapsed since the current
+ * time.  Once the grace-period sequence number has reached this value, it will
+ * be safe to invoke all callbacks that have been registered prior to the
+ * current 

Re: [PATCH v3 1/4] rcu: Add comment documenting how rcu_seq_snap works

2018-05-20 Thread Joel Fernandes
On Sun, May 20, 2018 at 09:50:25PM -0700, Randy Dunlap wrote:
> On 05/20/2018 09:42 PM, Joel Fernandes wrote:
> > rcu_seq_snap may be tricky to decipher. Lets document how it works with
> > an example to make it easier.
> > 
> > Signed-off-by: Joel Fernandes (Google) 
> > ---
> >  kernel/rcu/rcu.h | 33 -
> >  1 file changed, 32 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
> > index 0453a7d12b3f..d4396c96f614 100644
> > --- a/kernel/rcu/rcu.h
> > +++ b/kernel/rcu/rcu.h
> > @@ -91,7 +91,38 @@ static inline void rcu_seq_end(unsigned long *sp)
> > WRITE_ONCE(*sp, rcu_seq_endval(sp));
> >  }
> >  
> > -/* Take a snapshot of the update side's sequence number. */
> > +/*
> > + * rcu_seq_snap - Take a snapshot of the update side's sequence number.
> > + *
> > + * This function returns the earliest value of the grace-period sequence 
> > number
> > + * that will indicate that a full grace period has elapsed since the 
> > current
> > + * time.  Once the grace-period sequence number has reached this value, it 
> > will
> > + * be safe to invoke all callbacks that have been registered prior to the
> > + * current time. This value is the current grace-period number plus two to 
> > the
> > + * power of the number of low-order bits reserved for state, then rounded 
> > up to
> > + * the next value in which the state bits are all zero.
> > + *
> > + * For example, since RCU_SEQ_STATE_MASK=3 and the least significant bit of
> > + * the seq is used to track if a GP is in progress or not, its sufficient 
> > if we
> 
>   it's
> 
> > + * add (6+1) and mask with ~3 to get the next GP. Let's see why with an 
> > example:
> > + *
> > + * Say the current seq is 12 which is 0b1100 (GP is 3 and state bits are 
> > 0b00).
> > + * To get to the next GP number of 4, we have to add 0b100 to this (0x1 << 
> > 2)
> > + * to account for the shift due to 2 state bits. Now, if the current seq is
> > + * 13 (GP is 3 and state bits are 0b01), then it means the current grace 
> > period
> > + * is already in progress so the next GP that a future call back will be 
> > queued
> > + * to run at is GP+2 = 5, not 4. To account for the extra +1, we just 
> > overflow
> > + * the 2 lower bits by adding 0b11. Incase the lower bit was set, the 
> > overflow
> 
>In case
> 
> > + * will cause the extra +1 to the GP, along with the usual +1 explained 
> > before.
> > + * This gives us GP+2. Finally we mask the lower to bits by ~0x3 incase the
> 
> in case
> 
> > + * overflow didn't occur. This masking is needed because incase RCU was 
> > idle
> 
> in case
> 
> > + * (no GP in progress so lower 2 bits are 0b00), then the overflow of the 
> > lower
> > + * 2 state bits wouldn't occur, so we mask to zero out those lower 2 bits.
> > + *
> > + * In other words, the next seq can be obtained by (0b11 + 0b100) & (~0b11)
> > + * which can be generalized to:
> > + * seq + (RCU_SEQ_STATE_MASK + (RCU_SEQ_STATE_MASK + 1)) & 
> > (~RCU_SEQ_STATE_MASK)
> > + */
> >  static inline unsigned long rcu_seq_snap(unsigned long *sp)
> >  {
> > unsigned long s;
> > 
> 
> cheers.
> -- 
> ~Randy

Thanks Randy. Fixed, updated patch below. Paul, let me know if you want
me to send it separately or if you can pick it up from below.

Also I realize I need some better automated tools to catch these issues
(spelling errors in commit, diffs etc). Probably checkpatch.pl should
have such checks for these common things too.

--8<--

>From 1c1f8ce04bca656a3c07e555048545d4a59e44cf Mon Sep 17 00:00:00 2001
From: Joel Fernandes 
Date: Sun, 20 May 2018 19:37:18 -0700
Subject: [PATCH v3.5] rcu: Add comment documenting how rcu_seq_snap works

rcu_seq_snap may be tricky to decipher. Lets document how it works with
an example to make it easier.

Signed-off-by: Joel Fernandes (Google) 
---
 kernel/rcu/rcu.h | 33 -
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index 0453a7d12b3f..00df3da98317 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -91,7 +91,38 @@ static inline void rcu_seq_end(unsigned long *sp)
WRITE_ONCE(*sp, rcu_seq_endval(sp));
 }
 
-/* Take a snapshot of the update side's sequence number. */
+/*
+ * rcu_seq_snap - Take a snapshot of the update side's sequence number.
+ *
+ * This function returns the earliest value of the grace-period sequence number
+ * that will indicate that a full grace period has elapsed since the current
+ * time.  Once the grace-period sequence number has reached this value, it will
+ * be safe to invoke all callbacks that have been registered prior to the
+ * current time. This value is the current grace-period number plus two to the
+ * 

[PATCH RESEND] platform/chrome: cros_ec_lpc: Add support for newer Google devices using custom coreboot firmware or stock SeaBIOS.

2018-05-20 Thread Vittorio Gambaletta (VittGam)
Custom coreboot firmware does not contain "Google_*" as BIOS
version string; also, booting through stock SeaBIOS will present
an empty BIOS version string to Linux. So the generic match at
the top would not work.

A previous patch added the "GOOGLE" match for DMI system vendor,
but newer machines such as Skylake-based Caroline use "Google"
instead.

Also amend the previous comment adding a note that this is needed
for stock SeaBIOS too.

Signed-off-by: Vittorio Gambaletta 
Signed-off-by: Salvatore Bellizzi 

---

--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -347,7 +347,8 @@
},
{
/*
-* If the box is running custom coreboot firmware then the
+* If the box is running custom coreboot firmware,
+* or is booting Linux through stock SeaBIOS, then the
 * DMI BIOS version string will not be matched by "Google_",
 * but the system vendor string will still be matched by
 * "GOOGLE".
@@ -358,6 +359,16 @@
},
},
{
+   /*
+* Newer machines use "Google" instead of "GOOGLE" as
+* DMI system vendor string.
+*/
+   .matches = {
+   DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
+   DMI_MATCH(DMI_SYS_VENDOR, "Google"),
+   },
+   },
+   {
/* x86-link, the Chromebook Pixel. */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),


[PATCH RESEND] platform/chrome: cros_ec_lpc: Add support for newer Google devices using custom coreboot firmware or stock SeaBIOS.

2018-05-20 Thread Vittorio Gambaletta (VittGam)
Custom coreboot firmware does not contain "Google_*" as BIOS
version string; also, booting through stock SeaBIOS will present
an empty BIOS version string to Linux. So the generic match at
the top would not work.

A previous patch added the "GOOGLE" match for DMI system vendor,
but newer machines such as Skylake-based Caroline use "Google"
instead.

Also amend the previous comment adding a note that this is needed
for stock SeaBIOS too.

Signed-off-by: Vittorio Gambaletta 
Signed-off-by: Salvatore Bellizzi 

---

--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -347,7 +347,8 @@
},
{
/*
-* If the box is running custom coreboot firmware then the
+* If the box is running custom coreboot firmware,
+* or is booting Linux through stock SeaBIOS, then the
 * DMI BIOS version string will not be matched by "Google_",
 * but the system vendor string will still be matched by
 * "GOOGLE".
@@ -358,6 +359,16 @@
},
},
{
+   /*
+* Newer machines use "Google" instead of "GOOGLE" as
+* DMI system vendor string.
+*/
+   .matches = {
+   DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
+   DMI_MATCH(DMI_SYS_VENDOR, "Google"),
+   },
+   },
+   {
/* x86-link, the Chromebook Pixel. */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),


Re: [PATCH v2 07/11] cpufreq: tegra20: Remove unnecessary parentheses

2018-05-20 Thread Viresh Kumar
On 18-05-18, 23:06, Dmitry Osipenko wrote:
> Remove unnecessary parentheses as suggested by the checkpatch script.
> 
> Signed-off-by: Dmitry Osipenko 
> ---
>  drivers/cpufreq/tegra20-cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/tegra20-cpufreq.c 
> b/drivers/cpufreq/tegra20-cpufreq.c
> index df25e350c8e6..4b85a6733533 100644
> --- a/drivers/cpufreq/tegra20-cpufreq.c
> +++ b/drivers/cpufreq/tegra20-cpufreq.c
> @@ -50,7 +50,7 @@ static unsigned int tegra_get_intermediate(struct 
> cpufreq_policy *policy,
>* - we are already at it, i.e. policy->cur == ifreq
>* - index corresponds to ifreq
>*/
> - if ((freq_table[index].frequency == ifreq) || (policy->cur == ifreq))
> + if (freq_table[index].frequency == ifreq || policy->cur == ifreq)
>   return 0;
>  
>   return ifreq;

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH v2 07/11] cpufreq: tegra20: Remove unnecessary parentheses

2018-05-20 Thread Viresh Kumar
On 18-05-18, 23:06, Dmitry Osipenko wrote:
> Remove unnecessary parentheses as suggested by the checkpatch script.
> 
> Signed-off-by: Dmitry Osipenko 
> ---
>  drivers/cpufreq/tegra20-cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/tegra20-cpufreq.c 
> b/drivers/cpufreq/tegra20-cpufreq.c
> index df25e350c8e6..4b85a6733533 100644
> --- a/drivers/cpufreq/tegra20-cpufreq.c
> +++ b/drivers/cpufreq/tegra20-cpufreq.c
> @@ -50,7 +50,7 @@ static unsigned int tegra_get_intermediate(struct 
> cpufreq_policy *policy,
>* - we are already at it, i.e. policy->cur == ifreq
>* - index corresponds to ifreq
>*/
> - if ((freq_table[index].frequency == ifreq) || (policy->cur == ifreq))
> + if (freq_table[index].frequency == ifreq || policy->cur == ifreq)
>   return 0;
>  
>   return ifreq;

Acked-by: Viresh Kumar 

-- 
viresh


Re: [Xen-devel][RFC 2/3] xen/grant-table: Extend API to work with DMA buffers

2018-05-20 Thread Oleksandr Andrushchenko

On 05/19/2018 01:19 AM, Boris Ostrovsky wrote:

On 05/17/2018 04:26 AM, Oleksandr Andrushchenko wrote:

From: Oleksandr Andrushchenko 

Signed-off-by: Oleksandr Andrushchenko 
---
  drivers/xen/grant-table.c | 49 +++
  include/xen/grant_table.h |  7 ++
  2 files changed, 56 insertions(+)

diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index bb36b1e1dbcc..c27bcc420575 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -729,6 +729,55 @@ void gnttab_free_pages(int nr_pages, struct page **pages)
  }
  EXPORT_SYMBOL(gnttab_free_pages);
  
+int gnttab_dma_alloc_pages(struct device *dev, bool coherent,

+  int nr_pages, struct page **pages,
+  void **vaddr, dma_addr_t *dev_bus_addr)
+{
+   int i;
+   int ret;
+
+   ret = alloc_dma_xenballooned_pages(dev, coherent, nr_pages, pages,
+  vaddr, dev_bus_addr);
+   if (ret < 0)
+   return ret;
+
+   for (i = 0; i < nr_pages; i++) {
+#if BITS_PER_LONG < 64
+   struct xen_page_foreign *foreign;
+
+   foreign = kzalloc(sizeof(*foreign), GFP_KERNEL);
+   if (!foreign) {
+   gnttab_dma_free_pages(dev, flags, nr_pages, pages,
+ *vaddr, *dev_bus_addr);
+   return -ENOMEM;
+   }
+   set_page_private(pages[i], (unsigned long)foreign);
+#endif
+   SetPagePrivate(pages[i]);
+   }
+   return 0;
+}
+EXPORT_SYMBOL(gnttab_dma_alloc_pages);
+
+void gnttab_dma_free_pages(struct device *dev, bool coherent,
+  int nr_pages, struct page **pages,
+  void *vaddr, dma_addr_t dev_bus_addr)
+{
+   int i;
+
+   for (i = 0; i < nr_pages; i++) {
+   if (PagePrivate(pages[i])) {
+#if BITS_PER_LONG < 64
+   kfree((void *)page_private(pages[i]));
+#endif
+   ClearPagePrivate(pages[i]);
+   }
+   }
+   free_dma_xenballooned_pages(dev, coherent, nr_pages, pages,
+   vaddr, dev_bus_addr);
+}
+EXPORT_SYMBOL(gnttab_dma_free_pages);


Given that these routines look almost exactly like their non-dma
counterparts I wonder whether common code could be factored out.

Yes, this can be done

-boris





+
  /* Handling of paged out grant targets (GNTST_eagain) */
  #define MAX_DELAY 256
  static inline void
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index 34b1379f9777..20ee2b5ba965 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -195,6 +195,13 @@ void gnttab_free_auto_xlat_frames(void);
  int gnttab_alloc_pages(int nr_pages, struct page **pages);
  void gnttab_free_pages(int nr_pages, struct page **pages);
  
+int gnttab_dma_alloc_pages(struct device *dev, bool coherent,

+  int nr_pages, struct page **pages,
+  void **vaddr, dma_addr_t *dev_bus_addr);
+void gnttab_dma_free_pages(struct device *dev, bool coherent,
+  int nr_pages, struct page **pages,
+  void *vaddr, dma_addr_t dev_bus_addr);
+
  int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
struct gnttab_map_grant_ref *kmap_ops,
struct page **pages, unsigned int count);




Re: [Xen-devel][RFC 2/3] xen/grant-table: Extend API to work with DMA buffers

2018-05-20 Thread Oleksandr Andrushchenko

On 05/19/2018 01:19 AM, Boris Ostrovsky wrote:

On 05/17/2018 04:26 AM, Oleksandr Andrushchenko wrote:

From: Oleksandr Andrushchenko 

Signed-off-by: Oleksandr Andrushchenko 
---
  drivers/xen/grant-table.c | 49 +++
  include/xen/grant_table.h |  7 ++
  2 files changed, 56 insertions(+)

diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index bb36b1e1dbcc..c27bcc420575 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -729,6 +729,55 @@ void gnttab_free_pages(int nr_pages, struct page **pages)
  }
  EXPORT_SYMBOL(gnttab_free_pages);
  
+int gnttab_dma_alloc_pages(struct device *dev, bool coherent,

+  int nr_pages, struct page **pages,
+  void **vaddr, dma_addr_t *dev_bus_addr)
+{
+   int i;
+   int ret;
+
+   ret = alloc_dma_xenballooned_pages(dev, coherent, nr_pages, pages,
+  vaddr, dev_bus_addr);
+   if (ret < 0)
+   return ret;
+
+   for (i = 0; i < nr_pages; i++) {
+#if BITS_PER_LONG < 64
+   struct xen_page_foreign *foreign;
+
+   foreign = kzalloc(sizeof(*foreign), GFP_KERNEL);
+   if (!foreign) {
+   gnttab_dma_free_pages(dev, flags, nr_pages, pages,
+ *vaddr, *dev_bus_addr);
+   return -ENOMEM;
+   }
+   set_page_private(pages[i], (unsigned long)foreign);
+#endif
+   SetPagePrivate(pages[i]);
+   }
+   return 0;
+}
+EXPORT_SYMBOL(gnttab_dma_alloc_pages);
+
+void gnttab_dma_free_pages(struct device *dev, bool coherent,
+  int nr_pages, struct page **pages,
+  void *vaddr, dma_addr_t dev_bus_addr)
+{
+   int i;
+
+   for (i = 0; i < nr_pages; i++) {
+   if (PagePrivate(pages[i])) {
+#if BITS_PER_LONG < 64
+   kfree((void *)page_private(pages[i]));
+#endif
+   ClearPagePrivate(pages[i]);
+   }
+   }
+   free_dma_xenballooned_pages(dev, coherent, nr_pages, pages,
+   vaddr, dev_bus_addr);
+}
+EXPORT_SYMBOL(gnttab_dma_free_pages);


Given that these routines look almost exactly like their non-dma
counterparts I wonder whether common code could be factored out.

Yes, this can be done

-boris





+
  /* Handling of paged out grant targets (GNTST_eagain) */
  #define MAX_DELAY 256
  static inline void
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index 34b1379f9777..20ee2b5ba965 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -195,6 +195,13 @@ void gnttab_free_auto_xlat_frames(void);
  int gnttab_alloc_pages(int nr_pages, struct page **pages);
  void gnttab_free_pages(int nr_pages, struct page **pages);
  
+int gnttab_dma_alloc_pages(struct device *dev, bool coherent,

+  int nr_pages, struct page **pages,
+  void **vaddr, dma_addr_t *dev_bus_addr);
+void gnttab_dma_free_pages(struct device *dev, bool coherent,
+  int nr_pages, struct page **pages,
+  void *vaddr, dma_addr_t dev_bus_addr);
+
  int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
struct gnttab_map_grant_ref *kmap_ops,
struct page **pages, unsigned int count);




Re: [PATCH v2 03/11] cpufreq: tegra20: Clean up included headers

2018-05-20 Thread Viresh Kumar
On 18-05-18, 23:06, Dmitry Osipenko wrote:
> Remove unused/unneeded headers and sort them in the alphabet order.
> 
> Signed-off-by: Dmitry Osipenko 
> Acked-by: Thierry Reding 
> ---
>  drivers/cpufreq/tegra20-cpufreq.c | 12 
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/cpufreq/tegra20-cpufreq.c 
> b/drivers/cpufreq/tegra20-cpufreq.c
> index dd8a76a64a8e..bec1a50a8138 100644
> --- a/drivers/cpufreq/tegra20-cpufreq.c
> +++ b/drivers/cpufreq/tegra20-cpufreq.c
> @@ -16,16 +16,12 @@
>   *
>   */
>  
> -#include 
> -#include 
> -#include 
> -#include 
> +#include 
>  #include 
> -#include 
> -#include 
>  #include 
> -#include 
> -#include 
> +#include 
> +#include 
> +#include 
>  
>  static struct cpufreq_frequency_table freq_table[] = {
>   { .frequency = 216000 },

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH v2 03/11] cpufreq: tegra20: Clean up included headers

2018-05-20 Thread Viresh Kumar
On 18-05-18, 23:06, Dmitry Osipenko wrote:
> Remove unused/unneeded headers and sort them in the alphabet order.
> 
> Signed-off-by: Dmitry Osipenko 
> Acked-by: Thierry Reding 
> ---
>  drivers/cpufreq/tegra20-cpufreq.c | 12 
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/cpufreq/tegra20-cpufreq.c 
> b/drivers/cpufreq/tegra20-cpufreq.c
> index dd8a76a64a8e..bec1a50a8138 100644
> --- a/drivers/cpufreq/tegra20-cpufreq.c
> +++ b/drivers/cpufreq/tegra20-cpufreq.c
> @@ -16,16 +16,12 @@
>   *
>   */
>  
> -#include 
> -#include 
> -#include 
> -#include 
> +#include 
>  #include 
> -#include 
> -#include 
>  #include 
> -#include 
> -#include 
> +#include 
> +#include 
> +#include 
>  
>  static struct cpufreq_frequency_table freq_table[] = {
>   { .frequency = 216000 },

Acked-by: Viresh Kumar 

-- 
viresh


Re: [Xen-devel] [RFC 1/3] xen/balloon: Allow allocating DMA buffers

2018-05-20 Thread Oleksandr Andrushchenko

On 05/19/2018 01:04 AM, Boris Ostrovsky wrote:

On 05/17/2018 04:26 AM, Oleksandr Andrushchenko wrote:

From: Oleksandr Andrushchenko 


A commit message would be useful.

Sure, v1 will have it



Signed-off-by: Oleksandr Andrushchenko 

for (i = 0; i < nr_pages; i++) {
-   page = alloc_page(gfp);
-   if (page == NULL) {
-   nr_pages = i;
-   state = BP_EAGAIN;
-   break;
+   if (ext_pages) {
+   page = ext_pages[i];
+   } else {
+   page = alloc_page(gfp);
+   if (page == NULL) {
+   nr_pages = i;
+   state = BP_EAGAIN;
+   break;
+   }
}
scrub_page(page);
list_add(>lru, );
@@ -529,7 +565,7 @@ static enum bp_state decrease_reservation(unsigned long 
nr_pages, gfp_t gfp)
i = 0;
list_for_each_entry_safe(page, tmp, , lru) {
/* XENMEM_decrease_reservation requires a GFN */
-   frame_list[i++] = xen_page_to_gfn(page);
+   frames[i++] = xen_page_to_gfn(page);
  
  #ifdef CONFIG_XEN_HAVE_PVMMU

/*
@@ -552,18 +588,22 @@ static enum bp_state decrease_reservation(unsigned long 
nr_pages, gfp_t gfp)
  #endif
list_del(>lru);
  
-		balloon_append(page);

+   if (!ext_pages)
+   balloon_append(page);


So what you are proposing is not really ballooning. You are just
piggybacking on existing interfaces, aren't you?

Sort of. Basically I need to {increase|decrease}_reservation, not actually
allocating ballooned pages.
Do you think I can simply EXPORT_SYMBOL for {increase|decrease}_reservation?
Any other suggestion?

-boris



Thank you,
Oleksandr


Re: [Xen-devel] [RFC 1/3] xen/balloon: Allow allocating DMA buffers

2018-05-20 Thread Oleksandr Andrushchenko

On 05/19/2018 01:04 AM, Boris Ostrovsky wrote:

On 05/17/2018 04:26 AM, Oleksandr Andrushchenko wrote:

From: Oleksandr Andrushchenko 


A commit message would be useful.

Sure, v1 will have it



Signed-off-by: Oleksandr Andrushchenko 

for (i = 0; i < nr_pages; i++) {
-   page = alloc_page(gfp);
-   if (page == NULL) {
-   nr_pages = i;
-   state = BP_EAGAIN;
-   break;
+   if (ext_pages) {
+   page = ext_pages[i];
+   } else {
+   page = alloc_page(gfp);
+   if (page == NULL) {
+   nr_pages = i;
+   state = BP_EAGAIN;
+   break;
+   }
}
scrub_page(page);
list_add(>lru, );
@@ -529,7 +565,7 @@ static enum bp_state decrease_reservation(unsigned long 
nr_pages, gfp_t gfp)
i = 0;
list_for_each_entry_safe(page, tmp, , lru) {
/* XENMEM_decrease_reservation requires a GFN */
-   frame_list[i++] = xen_page_to_gfn(page);
+   frames[i++] = xen_page_to_gfn(page);
  
  #ifdef CONFIG_XEN_HAVE_PVMMU

/*
@@ -552,18 +588,22 @@ static enum bp_state decrease_reservation(unsigned long 
nr_pages, gfp_t gfp)
  #endif
list_del(>lru);
  
-		balloon_append(page);

+   if (!ext_pages)
+   balloon_append(page);


So what you are proposing is not really ballooning. You are just
piggybacking on existing interfaces, aren't you?

Sort of. Basically I need to {increase|decrease}_reservation, not actually
allocating ballooned pages.
Do you think I can simply EXPORT_SYMBOL for {increase|decrease}_reservation?
Any other suggestion?

-boris



Thank you,
Oleksandr


Re: [PATCH v4 05/31] kconfig: remove string expansion for mainmenu after yyparse()

2018-05-20 Thread Masahiro Yamada
2018-05-20 23:39 GMT+09:00 Sam Ravnborg :

>> @@ -544,10 +530,10 @@ void conf_parse(const char *name)
>>   if (!modules_sym)
>>   modules_sym = sym_find( "n" );
>>
>> - tmp = rootmenu.prompt->text;
>> - rootmenu.prompt->text = _(rootmenu.prompt->text);
>> - rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
>> - free((char*)tmp);
>> + if (!menu_has_prompt()) {
>> + current_entry = 
>> + menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
>
> Could this be something less specific?
> To help the other users of kconfig out is the wild.
>
> For example:
>
> menu_add_prompt(P_MENU, _("Main menu"), NULL);


OK, but this should be done as a separate work.

I am keeping the current string "Linux Kernel Configuration"



> Note, the added _() to make the text translateable.
>

Hmm, I just wonder how much helpful gettext things are...

Rather, it looks maintenance burden to me.
Once we add messages, it is difficult to change.


-- 
Best Regards
Masahiro Yamada


Re: [PATCH v4 05/31] kconfig: remove string expansion for mainmenu after yyparse()

2018-05-20 Thread Masahiro Yamada
2018-05-20 23:39 GMT+09:00 Sam Ravnborg :

>> @@ -544,10 +530,10 @@ void conf_parse(const char *name)
>>   if (!modules_sym)
>>   modules_sym = sym_find( "n" );
>>
>> - tmp = rootmenu.prompt->text;
>> - rootmenu.prompt->text = _(rootmenu.prompt->text);
>> - rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
>> - free((char*)tmp);
>> + if (!menu_has_prompt()) {
>> + current_entry = 
>> + menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
>
> Could this be something less specific?
> To help the other users of kconfig out is the wild.
>
> For example:
>
> menu_add_prompt(P_MENU, _("Main menu"), NULL);


OK, but this should be done as a separate work.

I am keeping the current string "Linux Kernel Configuration"



> Note, the added _() to make the text translateable.
>

Hmm, I just wonder how much helpful gettext things are...

Rather, it looks maintenance burden to me.
Once we add messages, it is difficult to change.


-- 
Best Regards
Masahiro Yamada


Re: [PATCH v4 07/31] kconfig: add built-in function support

2018-05-20 Thread Masahiro Yamada
Sam,

2018-05-20 23:50 GMT+09:00 Sam Ravnborg :
> On Thu, May 17, 2018 at 03:16:46PM +0900, Masahiro Yamada wrote:
>> This commit adds a new concept 'function' to do more text processing
>> in Kconfig.
>>
>> A function call looks like this:
>>
>>   $(function,arg1,arg2,arg3,...)
>>
>> This commit adds the basic infrastructure to expand functions.
>> Change the text expansion helpers to take arguments.
>>
>> Signed-off-by: Masahiro Yamada 
>> ---
>>
>> Changes in v4:
>>   - Error out if arguments more than FUNCTION_MAX_ARGS are passed
>>   - Use a comma as a delimiter between the function name and the
>> first argument
>>   - Check the number of arguments accepted by each function
>>   - Support delayed expansion of arguments.
>> This will be needed to implement 'if' function
>>
>> Changes in v3:
>>   - Split base infrastructure and 'shell' function
>> into separate patches.
>>
>> Changes in v2:
>>   - Use 'shell' for getting stdout from the comment.
>> It was 'shell-stdout' in the previous version.
>>   - Simplify the implementation since the expansion has been moved to
>> lexer.
>>
>>  scripts/kconfig/preprocess.c | 168 
>> ---
>>  1 file changed, 159 insertions(+), 9 deletions(-)
>>
>> diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
>> index 1bf506c..5be28ec 100644
>> --- a/scripts/kconfig/preprocess.c
>> +++ b/scripts/kconfig/preprocess.c
>> @@ -3,12 +3,17 @@
>>  // Copyright (C) 2018 Masahiro Yamada 
>>
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>>
>>  #include "list.h"
>>
>> +#define ARRAY_SIZE(arr)  (sizeof(arr) / sizeof((arr)[0]))
>> +
>> +static char *expand_string_with_args(const char *in, int argc, char 
>> *argv[]);
>> +
>>  static void __attribute__((noreturn)) pperror(const char *format, ...)
>>  {
>>   va_list ap;
>> @@ -88,9 +93,85 @@ void env_write_dep(FILE *f, const char *autoconfig_name)
>>   }
>>  }
>>
>> -static char *eval_clause(const char *in)
>> +/*
>> + * Built-in functions
>> + */
>> +struct function {
>> + const char *name;
>> + unsigned int min_args;
>> + unsigned int max_args;
>> + bool expand_args;
>> + char *(*func)(int argc, char *argv[], int old_argc, char *old_argv[]);
>> +};
> If a typedef was provided for the function then ...


Yes, I can do this,
but I may rather consider to simplify the code.


>> +
>> +static const struct function function_table[] = {
>> + /* Name MIN MAX EXP?Function */
>> +};
>> +
>> +#define FUNCTION_MAX_ARGS16
>> +
>> +static char *function_expand_arg_and_call(char *(*func)(int argc, char 
>> *argv[],
>> + int old_argc,
>> + char *old_argv[]),
>> +   int argc, char *argv[],
>> +   int old_argc, char *old_argv[])
> this could be much easier to read.
>
>> +{
>> + char *expanded_argv[FUNCTION_MAX_ARGS], *res;
>> + int i;
>> +
>> + for (i = 0; i < argc; i++)
>> + expanded_argv[i] = expand_string_with_args(argv[i],
>> +old_argc, old_argv);
>
> No check for too many arguments here - maybe it is done in some other place.

Right.
This has already been checked by eval_clause().


>> +
>> + res = func(argc, expanded_argv, 0, NULL);
>> +
>> + for (i = 0; i < argc; i++)
>> + free(expanded_argv[i]);
>> +
>> + return res;
>> +}
>> +
>> +static char *function_call(const char *name, int argc, char *argv[],
>> +int old_argc, char *old_argv[])
>> +{
>> + const struct function *f;
>> + int i;
>> +
>> + for (i = 0; i < ARRAY_SIZE(function_table); i++) {
>> + f = _table[i];
>> + if (strcmp(f->name, name))
>> + continue;
>> +
>> + if (argc < f->min_args)
>> + pperror("too few function arguments passed to '%s'",
>> + name);
>> +
>> + if (argc > f->max_args)
>> + pperror("too many function arguments passed to '%s'",
>> + name);
> Number of arguments checked here, but max_args is not assiged in this patch.

This is added to function_table[] by later patches.


>
>> +
>> + if (f->expand_args)
>> + return function_expand_arg_and_call(f->func, argc, 
>> argv,
>> + old_argc, 
>> old_argv);
>> + return f->func(argc, argv, old_argc, old_argv);
>> + }
>> +
>> + return NULL;
>> +}
>> +
>> +/*
>> + * Evaluate a clause with arguments.  argc/argv are arguments from the upper
>> + * function call.
>> + *
>> + * Returned string must be freed 

Re: [PATCH v4 07/31] kconfig: add built-in function support

2018-05-20 Thread Masahiro Yamada
Sam,

2018-05-20 23:50 GMT+09:00 Sam Ravnborg :
> On Thu, May 17, 2018 at 03:16:46PM +0900, Masahiro Yamada wrote:
>> This commit adds a new concept 'function' to do more text processing
>> in Kconfig.
>>
>> A function call looks like this:
>>
>>   $(function,arg1,arg2,arg3,...)
>>
>> This commit adds the basic infrastructure to expand functions.
>> Change the text expansion helpers to take arguments.
>>
>> Signed-off-by: Masahiro Yamada 
>> ---
>>
>> Changes in v4:
>>   - Error out if arguments more than FUNCTION_MAX_ARGS are passed
>>   - Use a comma as a delimiter between the function name and the
>> first argument
>>   - Check the number of arguments accepted by each function
>>   - Support delayed expansion of arguments.
>> This will be needed to implement 'if' function
>>
>> Changes in v3:
>>   - Split base infrastructure and 'shell' function
>> into separate patches.
>>
>> Changes in v2:
>>   - Use 'shell' for getting stdout from the comment.
>> It was 'shell-stdout' in the previous version.
>>   - Simplify the implementation since the expansion has been moved to
>> lexer.
>>
>>  scripts/kconfig/preprocess.c | 168 
>> ---
>>  1 file changed, 159 insertions(+), 9 deletions(-)
>>
>> diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
>> index 1bf506c..5be28ec 100644
>> --- a/scripts/kconfig/preprocess.c
>> +++ b/scripts/kconfig/preprocess.c
>> @@ -3,12 +3,17 @@
>>  // Copyright (C) 2018 Masahiro Yamada 
>>
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>>
>>  #include "list.h"
>>
>> +#define ARRAY_SIZE(arr)  (sizeof(arr) / sizeof((arr)[0]))
>> +
>> +static char *expand_string_with_args(const char *in, int argc, char 
>> *argv[]);
>> +
>>  static void __attribute__((noreturn)) pperror(const char *format, ...)
>>  {
>>   va_list ap;
>> @@ -88,9 +93,85 @@ void env_write_dep(FILE *f, const char *autoconfig_name)
>>   }
>>  }
>>
>> -static char *eval_clause(const char *in)
>> +/*
>> + * Built-in functions
>> + */
>> +struct function {
>> + const char *name;
>> + unsigned int min_args;
>> + unsigned int max_args;
>> + bool expand_args;
>> + char *(*func)(int argc, char *argv[], int old_argc, char *old_argv[]);
>> +};
> If a typedef was provided for the function then ...


Yes, I can do this,
but I may rather consider to simplify the code.


>> +
>> +static const struct function function_table[] = {
>> + /* Name MIN MAX EXP?Function */
>> +};
>> +
>> +#define FUNCTION_MAX_ARGS16
>> +
>> +static char *function_expand_arg_and_call(char *(*func)(int argc, char 
>> *argv[],
>> + int old_argc,
>> + char *old_argv[]),
>> +   int argc, char *argv[],
>> +   int old_argc, char *old_argv[])
> this could be much easier to read.
>
>> +{
>> + char *expanded_argv[FUNCTION_MAX_ARGS], *res;
>> + int i;
>> +
>> + for (i = 0; i < argc; i++)
>> + expanded_argv[i] = expand_string_with_args(argv[i],
>> +old_argc, old_argv);
>
> No check for too many arguments here - maybe it is done in some other place.

Right.
This has already been checked by eval_clause().


>> +
>> + res = func(argc, expanded_argv, 0, NULL);
>> +
>> + for (i = 0; i < argc; i++)
>> + free(expanded_argv[i]);
>> +
>> + return res;
>> +}
>> +
>> +static char *function_call(const char *name, int argc, char *argv[],
>> +int old_argc, char *old_argv[])
>> +{
>> + const struct function *f;
>> + int i;
>> +
>> + for (i = 0; i < ARRAY_SIZE(function_table); i++) {
>> + f = _table[i];
>> + if (strcmp(f->name, name))
>> + continue;
>> +
>> + if (argc < f->min_args)
>> + pperror("too few function arguments passed to '%s'",
>> + name);
>> +
>> + if (argc > f->max_args)
>> + pperror("too many function arguments passed to '%s'",
>> + name);
> Number of arguments checked here, but max_args is not assiged in this patch.

This is added to function_table[] by later patches.


>
>> +
>> + if (f->expand_args)
>> + return function_expand_arg_and_call(f->func, argc, 
>> argv,
>> + old_argc, 
>> old_argv);
>> + return f->func(argc, argv, old_argc, old_argv);
>> + }
>> +
>> + return NULL;
>> +}
>> +
>> +/*
>> + * Evaluate a clause with arguments.  argc/argv are arguments from the upper
>> + * function call.
>> + *
>> + * Returned string must be freed when done
>> + */
>> +static char *eval_clause(const char *in, int argc, char 

Re: [PATCH v2] schedutil: Allow cpufreq requests to be made even when kthread kicked

2018-05-20 Thread Viresh Kumar
On 18-05-18, 11:55, Joel Fernandes (Google.) wrote:
> From: "Joel Fernandes (Google)" 
> 
> Currently there is a chance of a schedutil cpufreq update request to be
> dropped if there is a pending update request. This pending request can
> be delayed if there is a scheduling delay of the irq_work and the wake
> up of the schedutil governor kthread.
> 
> A very bad scenario is when a schedutil request was already just made,
> such as to reduce the CPU frequency, then a newer request to increase
> CPU frequency (even sched deadline urgent frequency increase requests)
> can be dropped, even though the rate limits suggest that its Ok to
> process a request. This is because of the way the work_in_progress flag
> is used.
> 
> This patch improves the situation by allowing new requests to happen
> even though the old one is still being processed. Note that in this
> approach, if an irq_work was already issued, we just update next_freq
> and don't bother to queue another request so there's no extra work being
> done to make this happen.

Now that this isn't an RFC anymore, you shouldn't have added below
paragraph here. It could go to the comments section though.

> I had brought up this issue at the OSPM conference and Claudio had a
> discussion RFC with an alternate approach [1]. I prefer the approach as
> done in the patch below since it doesn't need any new flags and doesn't
> cause any other extra overhead.
> 
> [1] https://patchwork.kernel.org/patch/10384261/
> 
> LGTMed-by: Viresh Kumar 
> LGTMed-by: Juri Lelli 

Looks like a Tag you just invented ? :)

> CC: Viresh Kumar 
> CC: Rafael J. Wysocki 
> CC: Peter Zijlstra 
> CC: Ingo Molnar 
> CC: Patrick Bellasi 
> CC: Juri Lelli 
> Cc: Luca Abeni 
> CC: Joel Fernandes 
> CC: Todd Kjos 
> CC: clau...@evidence.eu.com
> CC: kernel-t...@android.com
> CC: linux...@vger.kernel.org
> Signed-off-by: Joel Fernandes (Google) 
> ---
> v1 -> v2: Minor style related changes.
> 
>  kernel/sched/cpufreq_schedutil.c | 34 
>  1 file changed, 26 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/sched/cpufreq_schedutil.c 
> b/kernel/sched/cpufreq_schedutil.c
> index e13df951aca7..5c482ec38610 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -92,9 +92,6 @@ static bool sugov_should_update_freq(struct sugov_policy 
> *sg_policy, u64 time)
>   !cpufreq_can_do_remote_dvfs(sg_policy->policy))
>   return false;
>  
> - if (sg_policy->work_in_progress)
> - return false;
> -
>   if (unlikely(sg_policy->need_freq_update)) {
>   sg_policy->need_freq_update = false;
>   /*
> @@ -128,7 +125,7 @@ static void sugov_update_commit(struct sugov_policy 
> *sg_policy, u64 time,
>  
>   policy->cur = next_freq;
>   trace_cpu_frequency(next_freq, smp_processor_id());
> - } else {
> + } else if (!sg_policy->work_in_progress) {
>   sg_policy->work_in_progress = true;
>   irq_work_queue(_policy->irq_work);
>   }
> @@ -291,6 +288,13 @@ static void sugov_update_single(struct update_util_data 
> *hook, u64 time,
>  
>   ignore_dl_rate_limit(sg_cpu, sg_policy);
>  
> + /*
> +  * For slow-switch systems, single policy requests can't run at the
> +  * moment if update is in progress, unless we acquire update_lock.
> +  */
> + if (sg_policy->work_in_progress)
> + return;
> +

I would still want this to go away :)

@Rafael, will it be fine to get locking in place for unshared policy
platforms ?

>   if (!sugov_should_update_freq(sg_policy, time))
>   return;
>  
> @@ -382,13 +386,27 @@ sugov_update_shared(struct update_util_data *hook, u64 
> time, unsigned int flags)
>  static void sugov_work(struct kthread_work *work)
>  {
>   struct sugov_policy *sg_policy = container_of(work, struct 
> sugov_policy, work);
> + unsigned int freq;
> + unsigned long flags;
> +
> + /*
> +  * Hold sg_policy->update_lock shortly to handle the case where:
> +  * incase sg_policy->next_freq is read here, and then updated by
> +  * sugov_update_shared just before work_in_progress is set to false
> +  * here, we may miss queueing the new update.
> +  *
> +  * Note: If a work was queued after the update_lock is released,
> +  * sugov_work will just be called again by kthread_work code; and the
> +  * request will be proceed before the sugov thread sleeps.
> +  */
> + raw_spin_lock_irqsave(_policy->update_lock, flags);
> + freq = sg_policy->next_freq;
> + sg_policy->work_in_progress = false;
> + 

Re: [PATCH v2] schedutil: Allow cpufreq requests to be made even when kthread kicked

2018-05-20 Thread Viresh Kumar
On 18-05-18, 11:55, Joel Fernandes (Google.) wrote:
> From: "Joel Fernandes (Google)" 
> 
> Currently there is a chance of a schedutil cpufreq update request to be
> dropped if there is a pending update request. This pending request can
> be delayed if there is a scheduling delay of the irq_work and the wake
> up of the schedutil governor kthread.
> 
> A very bad scenario is when a schedutil request was already just made,
> such as to reduce the CPU frequency, then a newer request to increase
> CPU frequency (even sched deadline urgent frequency increase requests)
> can be dropped, even though the rate limits suggest that its Ok to
> process a request. This is because of the way the work_in_progress flag
> is used.
> 
> This patch improves the situation by allowing new requests to happen
> even though the old one is still being processed. Note that in this
> approach, if an irq_work was already issued, we just update next_freq
> and don't bother to queue another request so there's no extra work being
> done to make this happen.

Now that this isn't an RFC anymore, you shouldn't have added below
paragraph here. It could go to the comments section though.

> I had brought up this issue at the OSPM conference and Claudio had a
> discussion RFC with an alternate approach [1]. I prefer the approach as
> done in the patch below since it doesn't need any new flags and doesn't
> cause any other extra overhead.
> 
> [1] https://patchwork.kernel.org/patch/10384261/
> 
> LGTMed-by: Viresh Kumar 
> LGTMed-by: Juri Lelli 

Looks like a Tag you just invented ? :)

> CC: Viresh Kumar 
> CC: Rafael J. Wysocki 
> CC: Peter Zijlstra 
> CC: Ingo Molnar 
> CC: Patrick Bellasi 
> CC: Juri Lelli 
> Cc: Luca Abeni 
> CC: Joel Fernandes 
> CC: Todd Kjos 
> CC: clau...@evidence.eu.com
> CC: kernel-t...@android.com
> CC: linux...@vger.kernel.org
> Signed-off-by: Joel Fernandes (Google) 
> ---
> v1 -> v2: Minor style related changes.
> 
>  kernel/sched/cpufreq_schedutil.c | 34 
>  1 file changed, 26 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/sched/cpufreq_schedutil.c 
> b/kernel/sched/cpufreq_schedutil.c
> index e13df951aca7..5c482ec38610 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -92,9 +92,6 @@ static bool sugov_should_update_freq(struct sugov_policy 
> *sg_policy, u64 time)
>   !cpufreq_can_do_remote_dvfs(sg_policy->policy))
>   return false;
>  
> - if (sg_policy->work_in_progress)
> - return false;
> -
>   if (unlikely(sg_policy->need_freq_update)) {
>   sg_policy->need_freq_update = false;
>   /*
> @@ -128,7 +125,7 @@ static void sugov_update_commit(struct sugov_policy 
> *sg_policy, u64 time,
>  
>   policy->cur = next_freq;
>   trace_cpu_frequency(next_freq, smp_processor_id());
> - } else {
> + } else if (!sg_policy->work_in_progress) {
>   sg_policy->work_in_progress = true;
>   irq_work_queue(_policy->irq_work);
>   }
> @@ -291,6 +288,13 @@ static void sugov_update_single(struct update_util_data 
> *hook, u64 time,
>  
>   ignore_dl_rate_limit(sg_cpu, sg_policy);
>  
> + /*
> +  * For slow-switch systems, single policy requests can't run at the
> +  * moment if update is in progress, unless we acquire update_lock.
> +  */
> + if (sg_policy->work_in_progress)
> + return;
> +

I would still want this to go away :)

@Rafael, will it be fine to get locking in place for unshared policy
platforms ?

>   if (!sugov_should_update_freq(sg_policy, time))
>   return;
>  
> @@ -382,13 +386,27 @@ sugov_update_shared(struct update_util_data *hook, u64 
> time, unsigned int flags)
>  static void sugov_work(struct kthread_work *work)
>  {
>   struct sugov_policy *sg_policy = container_of(work, struct 
> sugov_policy, work);
> + unsigned int freq;
> + unsigned long flags;
> +
> + /*
> +  * Hold sg_policy->update_lock shortly to handle the case where:
> +  * incase sg_policy->next_freq is read here, and then updated by
> +  * sugov_update_shared just before work_in_progress is set to false
> +  * here, we may miss queueing the new update.
> +  *
> +  * Note: If a work was queued after the update_lock is released,
> +  * sugov_work will just be called again by kthread_work code; and the
> +  * request will be proceed before the sugov thread sleeps.
> +  */
> + raw_spin_lock_irqsave(_policy->update_lock, flags);
> + freq = sg_policy->next_freq;
> + sg_policy->work_in_progress = false;
> + raw_spin_unlock_irqrestore(_policy->update_lock, flags);
>  
>   mutex_lock(_policy->work_lock);
> - __cpufreq_driver_target(sg_policy->policy, sg_policy->next_freq,
> - CPUFREQ_RELATION_L);
> + __cpufreq_driver_target(sg_policy->policy, freq, CPUFREQ_RELATION_L);
>   

Re: [PATCH] cpufreq: Add Kryo CPU scaling driver

2018-05-20 Thread Viresh Kumar
More comments after Russell's reply.

On 19-05-18, 14:35, Ilia Lin wrote:
> +static int __init qcom_cpufreq_kryo_driver_init(void)
> +{
> + struct device *cpu_dev_silver, *cpu_dev_gold;
> + struct opp_table *opp_silver, *opp_gold;
> + enum _msm8996_version msm8996_version;
> + struct nvmem_cell *speedbin_nvmem;
> + struct platform_device *pdev;
> + struct device_node *np;
> + u8 *speedbin;
> + u32 versions;
> + size_t len;
> + int ret;
> +
> + cpu_dev_silver = get_cpu_device(SILVER_LEAD);
> + if (IS_ERR_OR_NULL(cpu_dev_silver))

get_cpu_device() returns only NULL on error.

> + return PTR_ERR(cpu_dev_silver);
> +
> + cpu_dev_gold = get_cpu_device(SILVER_LEAD);
> + if (IS_ERR_OR_NULL(cpu_dev_gold))
> + return PTR_ERR(cpu_dev_gold);
> +
> + msm8996_version = qcom_cpufreq_kryo_get_msm_id();
> + if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
> + dev_err(cpu_dev_silver, "Not Snapdragon 820/821!");
> + return -ENODEV;
> + }
> +
> + np = dev_pm_opp_of_get_opp_desc_node(cpu_dev_silver);
> + if (IS_ERR_OR_NULL(np))

same here.

> + return PTR_ERR(np);
> +
> + if (!of_device_is_compatible(np, "operating-points-v2-kryo-cpu")) {
> + ret = -ENOENT;
> + goto free_np;
> + }
> +
> + speedbin_nvmem = of_nvmem_cell_get(np, NULL);
> + if (IS_ERR(speedbin_nvmem)) {
> + ret = PTR_ERR(speedbin_nvmem);
> + dev_err(cpu_dev_silver, "Could not get nvmem cell: %d\n", ret);
> + goto free_np;
> + }
> +
> + speedbin = nvmem_cell_read(speedbin_nvmem, );
> + nvmem_cell_put(speedbin_nvmem);
> +
> + switch (msm8996_version) {
> + case MSM8996_V3:
> + versions = 1 << (unsigned int)(*speedbin);
> + break;
> + case MSM8996_SG:
> + versions = 1 << ((unsigned int)(*speedbin) + 4);
> + break;
> + default:
> + BUG();
> + break;
> + }
> +
> + opp_silver = dev_pm_opp_set_supported_hw(cpu_dev_silver,,1);
> + if (IS_ERR(opp_silver)) {
> + dev_err(cpu_dev_silver, "Failed to set supported hardware\n");
> + ret = PTR_ERR(opp_silver);
> + goto free_np;
> + }
> +
> + opp_gold = dev_pm_opp_set_supported_hw(cpu_dev_gold,,1);
> + if (IS_ERR(opp_gold)) {
> + dev_err(cpu_dev_gold, "Failed to set supported hardware\n");
> + ret = PTR_ERR(opp_gold);
> + goto free_opp_silver;
> + }
> +
> + pdev = platform_device_register_simple("cpufreq-dt", -1, NULL, 0);

and this only returns ERR_PTR() on error.

> + if (!IS_ERR_OR_NULL(pdev))
> + return 0;
> +
> + ret = PTR_ERR(pdev);
> + dev_err(cpu_dev_silver, "Failed to register platform device\n");
> + dev_pm_opp_put_supported_hw(opp_gold);
> +
> +free_opp_silver:
> + dev_pm_opp_put_supported_hw(opp_silver);
> +
> +free_np:
> + of_node_put(np);
> +
> + return ret;
> +}
> +late_initcall(qcom_cpufreq_kryo_driver_init);
> +
> +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Kryo CPUfreq driver");
> +MODULE_LICENSE("GPL v2");
> -- 
> 1.9.1

-- 
viresh


Re: [PATCH] cpufreq: Add Kryo CPU scaling driver

2018-05-20 Thread Viresh Kumar
More comments after Russell's reply.

On 19-05-18, 14:35, Ilia Lin wrote:
> +static int __init qcom_cpufreq_kryo_driver_init(void)
> +{
> + struct device *cpu_dev_silver, *cpu_dev_gold;
> + struct opp_table *opp_silver, *opp_gold;
> + enum _msm8996_version msm8996_version;
> + struct nvmem_cell *speedbin_nvmem;
> + struct platform_device *pdev;
> + struct device_node *np;
> + u8 *speedbin;
> + u32 versions;
> + size_t len;
> + int ret;
> +
> + cpu_dev_silver = get_cpu_device(SILVER_LEAD);
> + if (IS_ERR_OR_NULL(cpu_dev_silver))

get_cpu_device() returns only NULL on error.

> + return PTR_ERR(cpu_dev_silver);
> +
> + cpu_dev_gold = get_cpu_device(SILVER_LEAD);
> + if (IS_ERR_OR_NULL(cpu_dev_gold))
> + return PTR_ERR(cpu_dev_gold);
> +
> + msm8996_version = qcom_cpufreq_kryo_get_msm_id();
> + if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
> + dev_err(cpu_dev_silver, "Not Snapdragon 820/821!");
> + return -ENODEV;
> + }
> +
> + np = dev_pm_opp_of_get_opp_desc_node(cpu_dev_silver);
> + if (IS_ERR_OR_NULL(np))

same here.

> + return PTR_ERR(np);
> +
> + if (!of_device_is_compatible(np, "operating-points-v2-kryo-cpu")) {
> + ret = -ENOENT;
> + goto free_np;
> + }
> +
> + speedbin_nvmem = of_nvmem_cell_get(np, NULL);
> + if (IS_ERR(speedbin_nvmem)) {
> + ret = PTR_ERR(speedbin_nvmem);
> + dev_err(cpu_dev_silver, "Could not get nvmem cell: %d\n", ret);
> + goto free_np;
> + }
> +
> + speedbin = nvmem_cell_read(speedbin_nvmem, );
> + nvmem_cell_put(speedbin_nvmem);
> +
> + switch (msm8996_version) {
> + case MSM8996_V3:
> + versions = 1 << (unsigned int)(*speedbin);
> + break;
> + case MSM8996_SG:
> + versions = 1 << ((unsigned int)(*speedbin) + 4);
> + break;
> + default:
> + BUG();
> + break;
> + }
> +
> + opp_silver = dev_pm_opp_set_supported_hw(cpu_dev_silver,,1);
> + if (IS_ERR(opp_silver)) {
> + dev_err(cpu_dev_silver, "Failed to set supported hardware\n");
> + ret = PTR_ERR(opp_silver);
> + goto free_np;
> + }
> +
> + opp_gold = dev_pm_opp_set_supported_hw(cpu_dev_gold,,1);
> + if (IS_ERR(opp_gold)) {
> + dev_err(cpu_dev_gold, "Failed to set supported hardware\n");
> + ret = PTR_ERR(opp_gold);
> + goto free_opp_silver;
> + }
> +
> + pdev = platform_device_register_simple("cpufreq-dt", -1, NULL, 0);

and this only returns ERR_PTR() on error.

> + if (!IS_ERR_OR_NULL(pdev))
> + return 0;
> +
> + ret = PTR_ERR(pdev);
> + dev_err(cpu_dev_silver, "Failed to register platform device\n");
> + dev_pm_opp_put_supported_hw(opp_gold);
> +
> +free_opp_silver:
> + dev_pm_opp_put_supported_hw(opp_silver);
> +
> +free_np:
> + of_node_put(np);
> +
> + return ret;
> +}
> +late_initcall(qcom_cpufreq_kryo_driver_init);
> +
> +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Kryo CPUfreq driver");
> +MODULE_LICENSE("GPL v2");
> -- 
> 1.9.1

-- 
viresh


Re: [PATCH v2 5/5] kconfig: refactor ncurses package checks for building nconf

2018-05-20 Thread Masahiro Yamada
2018-05-21 13:51 GMT+09:00 Randy Dunlap :
> On 05/20/2018 09:48 PM, Masahiro Yamada wrote:
>> 2018-05-21 8:41 GMT+09:00 Randy Dunlap :
>>> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:
 Building nconf requires ncurses, but its presence is not checked.
 Check and configure necessary packages by a shell script like the
 other GUI frontends.

 Signed-off-by: Masahiro Yamada 
 ---

>>>
 diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
 new file mode 100644
 index 000..8eb7948
 --- /dev/null
 +++ b/scripts/kconfig/nconf-cfg.sh
 @@ -0,0 +1,34 @@
 +#!/bin/sh
 +# SPDX-License-Identifier: GPL-2.0
 +
 +PKG="ncursesw menuw panelw"
 +PKG2="ncurses menu panel"
 +
 +if pkg-config --exists $PKG; then
 + echo libs=\"$(pkg-config --libs $PKG)\"
 + exit 0
 +fi
 +
 +if pkg-config --exists $PKG2; then
 + echo libs=\"$(pkg-config --libs $PKG2)\"
 + exit 0
 +fi
 +
>>>
>>> I guess this one needs clags, especially -I, like the mconf patch 
>>> contains...
>>
>>
>>
>> I thought so.
>>
>> But, the current scripts/kconfig/Makefile
>> adds 'pkg-config --libs' to nconf,
>> but does nothing about 'pkg-config --cflags' for nconf.
>> Therefore, I kept the current behavior just in case.
>>
>>
>> The nconfig in the current version is not working for you, right?
>
> That's correct.
>
>
> Info:
>
> $ make ARCH=x86_64 O=xx64 nconfig
> make[1]: Entering directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
>   GEN ./Makefile
>   UPD scripts/kconfig/.nconf-cfg
>   HOSTCC  scripts/kconfig/nconf.o
> In file included from ../scripts/kconfig/nconf.c:15:0:
> ../scripts/kconfig/nconf.h:19:18: fatal error: menu.h: No such file or 
> directory
>  #include 
>   ^
> compilation terminated.
> scripts/Makefile.host:107: recipe for target 'scripts/kconfig/nconf.o' failed
> make[2]: *** [scripts/kconfig/nconf.o] Error 1
> /home/rdunlap/lnx/next/linux-next-20180517/Makefile:525: recipe for target 
> 'nconfig' failed
> make[1]: *** [nconfig] Error 2
> make[1]: Leaving directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
> Makefile:146: recipe for target 'sub-make' failed
> make: *** [sub-make] Error 2
>
>
> xx64/scripts/kconfig/.nconf-cfg contains:
> libs="-lncursesw -lmenuw -lpanelw"
>

Sorry, I mean
the nconfig in the Linus tree is not working, right?



-- 
Best Regards
Masahiro Yamada


Re: [PATCH v2 5/5] kconfig: refactor ncurses package checks for building nconf

2018-05-20 Thread Masahiro Yamada
2018-05-21 13:51 GMT+09:00 Randy Dunlap :
> On 05/20/2018 09:48 PM, Masahiro Yamada wrote:
>> 2018-05-21 8:41 GMT+09:00 Randy Dunlap :
>>> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:
 Building nconf requires ncurses, but its presence is not checked.
 Check and configure necessary packages by a shell script like the
 other GUI frontends.

 Signed-off-by: Masahiro Yamada 
 ---

>>>
 diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
 new file mode 100644
 index 000..8eb7948
 --- /dev/null
 +++ b/scripts/kconfig/nconf-cfg.sh
 @@ -0,0 +1,34 @@
 +#!/bin/sh
 +# SPDX-License-Identifier: GPL-2.0
 +
 +PKG="ncursesw menuw panelw"
 +PKG2="ncurses menu panel"
 +
 +if pkg-config --exists $PKG; then
 + echo libs=\"$(pkg-config --libs $PKG)\"
 + exit 0
 +fi
 +
 +if pkg-config --exists $PKG2; then
 + echo libs=\"$(pkg-config --libs $PKG2)\"
 + exit 0
 +fi
 +
>>>
>>> I guess this one needs clags, especially -I, like the mconf patch 
>>> contains...
>>
>>
>>
>> I thought so.
>>
>> But, the current scripts/kconfig/Makefile
>> adds 'pkg-config --libs' to nconf,
>> but does nothing about 'pkg-config --cflags' for nconf.
>> Therefore, I kept the current behavior just in case.
>>
>>
>> The nconfig in the current version is not working for you, right?
>
> That's correct.
>
>
> Info:
>
> $ make ARCH=x86_64 O=xx64 nconfig
> make[1]: Entering directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
>   GEN ./Makefile
>   UPD scripts/kconfig/.nconf-cfg
>   HOSTCC  scripts/kconfig/nconf.o
> In file included from ../scripts/kconfig/nconf.c:15:0:
> ../scripts/kconfig/nconf.h:19:18: fatal error: menu.h: No such file or 
> directory
>  #include 
>   ^
> compilation terminated.
> scripts/Makefile.host:107: recipe for target 'scripts/kconfig/nconf.o' failed
> make[2]: *** [scripts/kconfig/nconf.o] Error 1
> /home/rdunlap/lnx/next/linux-next-20180517/Makefile:525: recipe for target 
> 'nconfig' failed
> make[1]: *** [nconfig] Error 2
> make[1]: Leaving directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
> Makefile:146: recipe for target 'sub-make' failed
> make: *** [sub-make] Error 2
>
>
> xx64/scripts/kconfig/.nconf-cfg contains:
> libs="-lncursesw -lmenuw -lpanelw"
>

Sorry, I mean
the nconfig in the Linus tree is not working, right?



-- 
Best Regards
Masahiro Yamada


Re: [PATCH v2] gpu: drm: udl: Adding new typedef vm_fault_t

2018-05-20 Thread Souptick Joarder
On Thu, May 10, 2018 at 7:18 PM, Souptick Joarder  wrote:
> On Wed, Apr 25, 2018 at 10:29 AM, Souptick Joarder  
> wrote:
>> Use new return type vm_fault_t for fault and huge_fault
>> handler. For now, this is just documenting that the
>> function returns a VM_FAULT value rather than an errno.
>> Once all instances are converted, vm_fault_t will become
>> a distinct type.
>>
>> Commit 1c8f422059ae ("mm: change return type to vm_fault_t")
>>
>> Previously vm_insert_page() returns err which driver
>> mapped into VM_FAULT_* type. The new function vmf_
>> insert_page() will replace this inefficiency by
>> returning VM_FAULT_* type.
>>
>> Signed-off-by: Souptick Joarder 
>> Reviewed-by: Matthew Wilcox 
>> ---
>> v2: Updated the change log
>>
>>  drivers/gpu/drm/udl/udl_drv.h |  3 ++-
>>  drivers/gpu/drm/udl/udl_gem.c | 15 ++-
>>  2 files changed, 4 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
>> index 2a75ab8..11151c4 100644
>> --- a/drivers/gpu/drm/udl/udl_drv.h
>> +++ b/drivers/gpu/drm/udl/udl_drv.h
>> @@ -16,6 +16,7 @@
>>
>>  #include 
>>  #include 
>> +#include 
>>
>>  #define DRIVER_NAME"udl"
>>  #define DRIVER_DESC"DisplayLink"
>> @@ -134,7 +135,7 @@ struct drm_gem_object *udl_gem_prime_import(struct 
>> drm_device *dev,
>>  int udl_gem_vmap(struct udl_gem_object *obj);
>>  void udl_gem_vunmap(struct udl_gem_object *obj);
>>  int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
>> -int udl_gem_fault(struct vm_fault *vmf);
>> +vm_fault_t udl_gem_fault(struct vm_fault *vmf);
>>
>>  int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
>>   int width, int height);
>> diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
>> index dee6bd9..cf5fe35 100644
>> --- a/drivers/gpu/drm/udl/udl_gem.c
>> +++ b/drivers/gpu/drm/udl/udl_gem.c
>> @@ -100,13 +100,12 @@ int udl_drm_gem_mmap(struct file *filp, struct 
>> vm_area_struct *vma)
>> return ret;
>>  }
>>
>> -int udl_gem_fault(struct vm_fault *vmf)
>> +vm_fault_t udl_gem_fault(struct vm_fault *vmf)
>>  {
>> struct vm_area_struct *vma = vmf->vma;
>> struct udl_gem_object *obj = to_udl_bo(vma->vm_private_data);
>> struct page *page;
>> unsigned int page_offset;
>> -   int ret = 0;
>>
>> page_offset = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
>>
>> @@ -114,17 +113,7 @@ int udl_gem_fault(struct vm_fault *vmf)
>> return VM_FAULT_SIGBUS;
>>
>> page = obj->pages[page_offset];
>> -   ret = vm_insert_page(vma, vmf->address, page);
>> -   switch (ret) {
>> -   case -EAGAIN:
>> -   case 0:
>> -   case -ERESTARTSYS:
>> -   return VM_FAULT_NOPAGE;
>> -   case -ENOMEM:
>> -   return VM_FAULT_OOM;
>> -   default:
>> -   return VM_FAULT_SIGBUS;
>> -   }
>> +   return vmf_insert_page(vma, vmf->address, page);
>>  }
>>
>>  int udl_gem_get_pages(struct udl_gem_object *obj)
>> --
>> 1.9.1
>>
>
> Any comment on this patch ?

If no comment, we would like to get this patch in queue
for 4.18.


Re: [PATCH v2] gpu: drm: udl: Adding new typedef vm_fault_t

2018-05-20 Thread Souptick Joarder
On Thu, May 10, 2018 at 7:18 PM, Souptick Joarder  wrote:
> On Wed, Apr 25, 2018 at 10:29 AM, Souptick Joarder  
> wrote:
>> Use new return type vm_fault_t for fault and huge_fault
>> handler. For now, this is just documenting that the
>> function returns a VM_FAULT value rather than an errno.
>> Once all instances are converted, vm_fault_t will become
>> a distinct type.
>>
>> Commit 1c8f422059ae ("mm: change return type to vm_fault_t")
>>
>> Previously vm_insert_page() returns err which driver
>> mapped into VM_FAULT_* type. The new function vmf_
>> insert_page() will replace this inefficiency by
>> returning VM_FAULT_* type.
>>
>> Signed-off-by: Souptick Joarder 
>> Reviewed-by: Matthew Wilcox 
>> ---
>> v2: Updated the change log
>>
>>  drivers/gpu/drm/udl/udl_drv.h |  3 ++-
>>  drivers/gpu/drm/udl/udl_gem.c | 15 ++-
>>  2 files changed, 4 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
>> index 2a75ab8..11151c4 100644
>> --- a/drivers/gpu/drm/udl/udl_drv.h
>> +++ b/drivers/gpu/drm/udl/udl_drv.h
>> @@ -16,6 +16,7 @@
>>
>>  #include 
>>  #include 
>> +#include 
>>
>>  #define DRIVER_NAME"udl"
>>  #define DRIVER_DESC"DisplayLink"
>> @@ -134,7 +135,7 @@ struct drm_gem_object *udl_gem_prime_import(struct 
>> drm_device *dev,
>>  int udl_gem_vmap(struct udl_gem_object *obj);
>>  void udl_gem_vunmap(struct udl_gem_object *obj);
>>  int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
>> -int udl_gem_fault(struct vm_fault *vmf);
>> +vm_fault_t udl_gem_fault(struct vm_fault *vmf);
>>
>>  int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
>>   int width, int height);
>> diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
>> index dee6bd9..cf5fe35 100644
>> --- a/drivers/gpu/drm/udl/udl_gem.c
>> +++ b/drivers/gpu/drm/udl/udl_gem.c
>> @@ -100,13 +100,12 @@ int udl_drm_gem_mmap(struct file *filp, struct 
>> vm_area_struct *vma)
>> return ret;
>>  }
>>
>> -int udl_gem_fault(struct vm_fault *vmf)
>> +vm_fault_t udl_gem_fault(struct vm_fault *vmf)
>>  {
>> struct vm_area_struct *vma = vmf->vma;
>> struct udl_gem_object *obj = to_udl_bo(vma->vm_private_data);
>> struct page *page;
>> unsigned int page_offset;
>> -   int ret = 0;
>>
>> page_offset = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
>>
>> @@ -114,17 +113,7 @@ int udl_gem_fault(struct vm_fault *vmf)
>> return VM_FAULT_SIGBUS;
>>
>> page = obj->pages[page_offset];
>> -   ret = vm_insert_page(vma, vmf->address, page);
>> -   switch (ret) {
>> -   case -EAGAIN:
>> -   case 0:
>> -   case -ERESTARTSYS:
>> -   return VM_FAULT_NOPAGE;
>> -   case -ENOMEM:
>> -   return VM_FAULT_OOM;
>> -   default:
>> -   return VM_FAULT_SIGBUS;
>> -   }
>> +   return vmf_insert_page(vma, vmf->address, page);
>>  }
>>
>>  int udl_gem_get_pages(struct udl_gem_object *obj)
>> --
>> 1.9.1
>>
>
> Any comment on this patch ?

If no comment, we would like to get this patch in queue
for 4.18.


Re: [PATCH v2 5/5] kconfig: refactor ncurses package checks for building nconf

2018-05-20 Thread Randy Dunlap
On 05/20/2018 09:48 PM, Masahiro Yamada wrote:
> 2018-05-21 8:41 GMT+09:00 Randy Dunlap :
>> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:
>>> Building nconf requires ncurses, but its presence is not checked.
>>> Check and configure necessary packages by a shell script like the
>>> other GUI frontends.
>>>
>>> Signed-off-by: Masahiro Yamada 
>>> ---
>>>
>>
>>> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
>>> new file mode 100644
>>> index 000..8eb7948
>>> --- /dev/null
>>> +++ b/scripts/kconfig/nconf-cfg.sh
>>> @@ -0,0 +1,34 @@
>>> +#!/bin/sh
>>> +# SPDX-License-Identifier: GPL-2.0
>>> +
>>> +PKG="ncursesw menuw panelw"
>>> +PKG2="ncurses menu panel"
>>> +
>>> +if pkg-config --exists $PKG; then
>>> + echo libs=\"$(pkg-config --libs $PKG)\"
>>> + exit 0
>>> +fi
>>> +
>>> +if pkg-config --exists $PKG2; then
>>> + echo libs=\"$(pkg-config --libs $PKG2)\"
>>> + exit 0
>>> +fi
>>> +
>>
>> I guess this one needs clags, especially -I, like the mconf patch contains...
> 
> 
> 
> I thought so.
> 
> But, the current scripts/kconfig/Makefile
> adds 'pkg-config --libs' to nconf,
> but does nothing about 'pkg-config --cflags' for nconf.
> Therefore, I kept the current behavior just in case.
> 
> 
> The nconfig in the current version is not working for you, right?

That's correct.


Info:

$ make ARCH=x86_64 O=xx64 nconfig
make[1]: Entering directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
  GEN ./Makefile
  UPD scripts/kconfig/.nconf-cfg
  HOSTCC  scripts/kconfig/nconf.o
In file included from ../scripts/kconfig/nconf.c:15:0:
../scripts/kconfig/nconf.h:19:18: fatal error: menu.h: No such file or directory
 #include 
  ^
compilation terminated.
scripts/Makefile.host:107: recipe for target 'scripts/kconfig/nconf.o' failed
make[2]: *** [scripts/kconfig/nconf.o] Error 1
/home/rdunlap/lnx/next/linux-next-20180517/Makefile:525: recipe for target 
'nconfig' failed
make[1]: *** [nconfig] Error 2
make[1]: Leaving directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
Makefile:146: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2


xx64/scripts/kconfig/.nconf-cfg contains:
libs="-lncursesw -lmenuw -lpanelw"


>>> +# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
>>> +# by pkg-config.
>>> +if [ -f /usr/include/ncursesw/ncurses.h ]; then
>>> + echo libs=\"-lncursesw -lmenuw -lpanelw\"
>>> + exit 0
>>> +fi
>>> +
>>> +if [ -f /usr/include/ncurses.h ]; then
>>> + echo libs=\"-lncurses -lmenu -lpanel\"
>>> + exit 0
>>> +fi
>>> +
>>> +echo >&2 "*"
>>> +echo >&2 "* Unable to find the ncurses."
>>
>>   the ncurses package."
>>
>>> +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
>>> +echo >&2 "* depending on your distribution)"
>>
>>  distribution)."
>>
>>> +echo >&2 "*"
>>> +exit 1
>>>
> 
> 
> 


-- 
~Randy


Re: [PATCH v2 5/5] kconfig: refactor ncurses package checks for building nconf

2018-05-20 Thread Randy Dunlap
On 05/20/2018 09:48 PM, Masahiro Yamada wrote:
> 2018-05-21 8:41 GMT+09:00 Randy Dunlap :
>> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:
>>> Building nconf requires ncurses, but its presence is not checked.
>>> Check and configure necessary packages by a shell script like the
>>> other GUI frontends.
>>>
>>> Signed-off-by: Masahiro Yamada 
>>> ---
>>>
>>
>>> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
>>> new file mode 100644
>>> index 000..8eb7948
>>> --- /dev/null
>>> +++ b/scripts/kconfig/nconf-cfg.sh
>>> @@ -0,0 +1,34 @@
>>> +#!/bin/sh
>>> +# SPDX-License-Identifier: GPL-2.0
>>> +
>>> +PKG="ncursesw menuw panelw"
>>> +PKG2="ncurses menu panel"
>>> +
>>> +if pkg-config --exists $PKG; then
>>> + echo libs=\"$(pkg-config --libs $PKG)\"
>>> + exit 0
>>> +fi
>>> +
>>> +if pkg-config --exists $PKG2; then
>>> + echo libs=\"$(pkg-config --libs $PKG2)\"
>>> + exit 0
>>> +fi
>>> +
>>
>> I guess this one needs clags, especially -I, like the mconf patch contains...
> 
> 
> 
> I thought so.
> 
> But, the current scripts/kconfig/Makefile
> adds 'pkg-config --libs' to nconf,
> but does nothing about 'pkg-config --cflags' for nconf.
> Therefore, I kept the current behavior just in case.
> 
> 
> The nconfig in the current version is not working for you, right?

That's correct.


Info:

$ make ARCH=x86_64 O=xx64 nconfig
make[1]: Entering directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
  GEN ./Makefile
  UPD scripts/kconfig/.nconf-cfg
  HOSTCC  scripts/kconfig/nconf.o
In file included from ../scripts/kconfig/nconf.c:15:0:
../scripts/kconfig/nconf.h:19:18: fatal error: menu.h: No such file or directory
 #include 
  ^
compilation terminated.
scripts/Makefile.host:107: recipe for target 'scripts/kconfig/nconf.o' failed
make[2]: *** [scripts/kconfig/nconf.o] Error 1
/home/rdunlap/lnx/next/linux-next-20180517/Makefile:525: recipe for target 
'nconfig' failed
make[1]: *** [nconfig] Error 2
make[1]: Leaving directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
Makefile:146: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2


xx64/scripts/kconfig/.nconf-cfg contains:
libs="-lncursesw -lmenuw -lpanelw"


>>> +# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
>>> +# by pkg-config.
>>> +if [ -f /usr/include/ncursesw/ncurses.h ]; then
>>> + echo libs=\"-lncursesw -lmenuw -lpanelw\"
>>> + exit 0
>>> +fi
>>> +
>>> +if [ -f /usr/include/ncurses.h ]; then
>>> + echo libs=\"-lncurses -lmenu -lpanel\"
>>> + exit 0
>>> +fi
>>> +
>>> +echo >&2 "*"
>>> +echo >&2 "* Unable to find the ncurses."
>>
>>   the ncurses package."
>>
>>> +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
>>> +echo >&2 "* depending on your distribution)"
>>
>>  distribution)."
>>
>>> +echo >&2 "*"
>>> +exit 1
>>>
> 
> 
> 


-- 
~Randy


Re: [PATCH v3 1/4] rcu: Add comment documenting how rcu_seq_snap works

2018-05-20 Thread Randy Dunlap
On 05/20/2018 09:42 PM, Joel Fernandes wrote:
> rcu_seq_snap may be tricky to decipher. Lets document how it works with
> an example to make it easier.
> 
> Signed-off-by: Joel Fernandes (Google) 
> ---
>  kernel/rcu/rcu.h | 33 -
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
> index 0453a7d12b3f..d4396c96f614 100644
> --- a/kernel/rcu/rcu.h
> +++ b/kernel/rcu/rcu.h
> @@ -91,7 +91,38 @@ static inline void rcu_seq_end(unsigned long *sp)
>   WRITE_ONCE(*sp, rcu_seq_endval(sp));
>  }
>  
> -/* Take a snapshot of the update side's sequence number. */
> +/*
> + * rcu_seq_snap - Take a snapshot of the update side's sequence number.
> + *
> + * This function returns the earliest value of the grace-period sequence 
> number
> + * that will indicate that a full grace period has elapsed since the current
> + * time.  Once the grace-period sequence number has reached this value, it 
> will
> + * be safe to invoke all callbacks that have been registered prior to the
> + * current time. This value is the current grace-period number plus two to 
> the
> + * power of the number of low-order bits reserved for state, then rounded up 
> to
> + * the next value in which the state bits are all zero.
> + *
> + * For example, since RCU_SEQ_STATE_MASK=3 and the least significant bit of
> + * the seq is used to track if a GP is in progress or not, its sufficient if 
> we

  it's

> + * add (6+1) and mask with ~3 to get the next GP. Let's see why with an 
> example:
> + *
> + * Say the current seq is 12 which is 0b1100 (GP is 3 and state bits are 
> 0b00).
> + * To get to the next GP number of 4, we have to add 0b100 to this (0x1 << 2)
> + * to account for the shift due to 2 state bits. Now, if the current seq is
> + * 13 (GP is 3 and state bits are 0b01), then it means the current grace 
> period
> + * is already in progress so the next GP that a future call back will be 
> queued
> + * to run at is GP+2 = 5, not 4. To account for the extra +1, we just 
> overflow
> + * the 2 lower bits by adding 0b11. Incase the lower bit was set, the 
> overflow

   In case

> + * will cause the extra +1 to the GP, along with the usual +1 explained 
> before.
> + * This gives us GP+2. Finally we mask the lower to bits by ~0x3 incase the

in case

> + * overflow didn't occur. This masking is needed because incase RCU was idle

in case

> + * (no GP in progress so lower 2 bits are 0b00), then the overflow of the 
> lower
> + * 2 state bits wouldn't occur, so we mask to zero out those lower 2 bits.
> + *
> + * In other words, the next seq can be obtained by (0b11 + 0b100) & (~0b11)
> + * which can be generalized to:
> + * seq + (RCU_SEQ_STATE_MASK + (RCU_SEQ_STATE_MASK + 1)) & 
> (~RCU_SEQ_STATE_MASK)
> + */
>  static inline unsigned long rcu_seq_snap(unsigned long *sp)
>  {
>   unsigned long s;
> 

cheers.
-- 
~Randy


Re: [PATCH v3 1/4] rcu: Add comment documenting how rcu_seq_snap works

2018-05-20 Thread Randy Dunlap
On 05/20/2018 09:42 PM, Joel Fernandes wrote:
> rcu_seq_snap may be tricky to decipher. Lets document how it works with
> an example to make it easier.
> 
> Signed-off-by: Joel Fernandes (Google) 
> ---
>  kernel/rcu/rcu.h | 33 -
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
> index 0453a7d12b3f..d4396c96f614 100644
> --- a/kernel/rcu/rcu.h
> +++ b/kernel/rcu/rcu.h
> @@ -91,7 +91,38 @@ static inline void rcu_seq_end(unsigned long *sp)
>   WRITE_ONCE(*sp, rcu_seq_endval(sp));
>  }
>  
> -/* Take a snapshot of the update side's sequence number. */
> +/*
> + * rcu_seq_snap - Take a snapshot of the update side's sequence number.
> + *
> + * This function returns the earliest value of the grace-period sequence 
> number
> + * that will indicate that a full grace period has elapsed since the current
> + * time.  Once the grace-period sequence number has reached this value, it 
> will
> + * be safe to invoke all callbacks that have been registered prior to the
> + * current time. This value is the current grace-period number plus two to 
> the
> + * power of the number of low-order bits reserved for state, then rounded up 
> to
> + * the next value in which the state bits are all zero.
> + *
> + * For example, since RCU_SEQ_STATE_MASK=3 and the least significant bit of
> + * the seq is used to track if a GP is in progress or not, its sufficient if 
> we

  it's

> + * add (6+1) and mask with ~3 to get the next GP. Let's see why with an 
> example:
> + *
> + * Say the current seq is 12 which is 0b1100 (GP is 3 and state bits are 
> 0b00).
> + * To get to the next GP number of 4, we have to add 0b100 to this (0x1 << 2)
> + * to account for the shift due to 2 state bits. Now, if the current seq is
> + * 13 (GP is 3 and state bits are 0b01), then it means the current grace 
> period
> + * is already in progress so the next GP that a future call back will be 
> queued
> + * to run at is GP+2 = 5, not 4. To account for the extra +1, we just 
> overflow
> + * the 2 lower bits by adding 0b11. Incase the lower bit was set, the 
> overflow

   In case

> + * will cause the extra +1 to the GP, along with the usual +1 explained 
> before.
> + * This gives us GP+2. Finally we mask the lower to bits by ~0x3 incase the

in case

> + * overflow didn't occur. This masking is needed because incase RCU was idle

in case

> + * (no GP in progress so lower 2 bits are 0b00), then the overflow of the 
> lower
> + * 2 state bits wouldn't occur, so we mask to zero out those lower 2 bits.
> + *
> + * In other words, the next seq can be obtained by (0b11 + 0b100) & (~0b11)
> + * which can be generalized to:
> + * seq + (RCU_SEQ_STATE_MASK + (RCU_SEQ_STATE_MASK + 1)) & 
> (~RCU_SEQ_STATE_MASK)
> + */
>  static inline unsigned long rcu_seq_snap(unsigned long *sp)
>  {
>   unsigned long s;
> 

cheers.
-- 
~Randy


Re: [PATCH v2 5/5] kconfig: refactor ncurses package checks for building nconf

2018-05-20 Thread Masahiro Yamada
2018-05-21 8:41 GMT+09:00 Randy Dunlap :
> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:
>> Building nconf requires ncurses, but its presence is not checked.
>> Check and configure necessary packages by a shell script like the
>> other GUI frontends.
>>
>> Signed-off-by: Masahiro Yamada 
>> ---
>>
>
>> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
>> new file mode 100644
>> index 000..8eb7948
>> --- /dev/null
>> +++ b/scripts/kconfig/nconf-cfg.sh
>> @@ -0,0 +1,34 @@
>> +#!/bin/sh
>> +# SPDX-License-Identifier: GPL-2.0
>> +
>> +PKG="ncursesw menuw panelw"
>> +PKG2="ncurses menu panel"
>> +
>> +if pkg-config --exists $PKG; then
>> + echo libs=\"$(pkg-config --libs $PKG)\"
>> + exit 0
>> +fi
>> +
>> +if pkg-config --exists $PKG2; then
>> + echo libs=\"$(pkg-config --libs $PKG2)\"
>> + exit 0
>> +fi
>> +
>
> I guess this one needs clags, especially -I, like the mconf patch contains...



I thought so.

But, the current scripts/kconfig/Makefile
adds 'pkg-config --libs' to nconf,
but does nothing about 'pkg-config --cflags' for nconf.
Therefore, I kept the current behavior just in case.


The nconfig in the current version is not working for you, right?




>
>> +# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
>> +# by pkg-config.
>> +if [ -f /usr/include/ncursesw/ncurses.h ]; then
>> + echo libs=\"-lncursesw -lmenuw -lpanelw\"
>> + exit 0
>> +fi
>> +
>> +if [ -f /usr/include/ncurses.h ]; then
>> + echo libs=\"-lncurses -lmenu -lpanel\"
>> + exit 0
>> +fi
>> +
>> +echo >&2 "*"
>> +echo >&2 "* Unable to find the ncurses."
>
>   the ncurses package."
>
>> +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
>> +echo >&2 "* depending on your distribution)"
>
>  distribution)."
>
>> +echo >&2 "*"
>> +exit 1
>>



-- 
Best Regards
Masahiro Yamada


Re: [PATCH v2 5/5] kconfig: refactor ncurses package checks for building nconf

2018-05-20 Thread Masahiro Yamada
2018-05-21 8:41 GMT+09:00 Randy Dunlap :
> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:
>> Building nconf requires ncurses, but its presence is not checked.
>> Check and configure necessary packages by a shell script like the
>> other GUI frontends.
>>
>> Signed-off-by: Masahiro Yamada 
>> ---
>>
>
>> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
>> new file mode 100644
>> index 000..8eb7948
>> --- /dev/null
>> +++ b/scripts/kconfig/nconf-cfg.sh
>> @@ -0,0 +1,34 @@
>> +#!/bin/sh
>> +# SPDX-License-Identifier: GPL-2.0
>> +
>> +PKG="ncursesw menuw panelw"
>> +PKG2="ncurses menu panel"
>> +
>> +if pkg-config --exists $PKG; then
>> + echo libs=\"$(pkg-config --libs $PKG)\"
>> + exit 0
>> +fi
>> +
>> +if pkg-config --exists $PKG2; then
>> + echo libs=\"$(pkg-config --libs $PKG2)\"
>> + exit 0
>> +fi
>> +
>
> I guess this one needs clags, especially -I, like the mconf patch contains...



I thought so.

But, the current scripts/kconfig/Makefile
adds 'pkg-config --libs' to nconf,
but does nothing about 'pkg-config --cflags' for nconf.
Therefore, I kept the current behavior just in case.


The nconfig in the current version is not working for you, right?




>
>> +# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
>> +# by pkg-config.
>> +if [ -f /usr/include/ncursesw/ncurses.h ]; then
>> + echo libs=\"-lncursesw -lmenuw -lpanelw\"
>> + exit 0
>> +fi
>> +
>> +if [ -f /usr/include/ncurses.h ]; then
>> + echo libs=\"-lncurses -lmenu -lpanel\"
>> + exit 0
>> +fi
>> +
>> +echo >&2 "*"
>> +echo >&2 "* Unable to find the ncurses."
>
>   the ncurses package."
>
>> +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
>> +echo >&2 "* depending on your distribution)"
>
>  distribution)."
>
>> +echo >&2 "*"
>> +exit 1
>>



-- 
Best Regards
Masahiro Yamada


Re: [PATCH v8 10/15] cpufreq: Add Kryo CPU scaling driver

2018-05-20 Thread Viresh Kumar
On 19-05-18, 14:45, ilia...@codeaurora.org wrote:
> Hi Viresh,
> 
> If I send patches in reply, it will produce new patches, instead of answers
> in the thread. Please find below the file dump.

There is one email from you which appears to be just fine and appears
to be in reply to this thread only. Maybe its your email client that
screwed it up for you ? Things look good in mutt.

-- 
viresh


Re: [PATCH v8 10/15] cpufreq: Add Kryo CPU scaling driver

2018-05-20 Thread Viresh Kumar
On 19-05-18, 14:45, ilia...@codeaurora.org wrote:
> Hi Viresh,
> 
> If I send patches in reply, it will produce new patches, instead of answers
> in the thread. Please find below the file dump.

There is one email from you which appears to be just fine and appears
to be in reply to this thread only. Maybe its your email client that
screwed it up for you ? Things look good in mutt.

-- 
viresh


Re: [PATCH v4 03/31] kconfig: reference environment variables directly and remove 'option env='

2018-05-20 Thread Masahiro Yamada
Hi.



2018-05-21 0:46 GMT+09:00 Ulf Magnusson :

> s/environments/environment variables/

Will fix.


>
>> +* They will be written out to include/config/auto.conf.cmd
>> +*/
>> +   env_add(name, value);
>> +
>> +   return xstrdup(value);
>> +}
>> +
>> +void env_write_dep(FILE *f, const char *autoconfig_name)
>> +{
>> +   struct env *e, *tmp;
>> +
>> +   list_for_each_entry_safe(e, tmp, _list, node) {
>> +   fprintf(f, "ifneq \"$(%s)\" \"%s\"\n", e->name, e->value);
>> +   fprintf(f, "%s: FORCE\n", autoconfig_name);
>> +   fprintf(f, "endif\n");
>> +   env_del(e);
>> +   }
>> +}
>> +
>> +static char *eval_clause(const char *in)
>> +{
>> +   char *res, *name;
>> +
>> +   /*
>> +* Returns an empty string because '$()' should be evaluated
>> +* to a null string.
>> +*/
>
> Do you know of cases where this is more useful than erroring out?
>
> Not saying it doesn't make sense. Just curious.


I just followed how Make works.

Anyway, eval_clause() will return null string for null input.
I will remove that hunk.




>> +   if (!*in)
>> +   return xstrdup("");
>> +
>> +   name = expand_string(in);
>> +
>> +   res = env_expand(name);
>> +   free(name);
>> +
>> +   return res;
>> +}
>> +
>> +/*
>> + * Expand a string that follows '$'
>> + *
>> + * For example, if the input string is
>> + * ($(FOO)$($(BAR)))$(BAZ)
>> + * this helper evaluates
>> + * $($(FOO)$($(BAR)))
>> + * and returns the resulted string, then updates 'str' to point to the next
>
> s/resulted/resulting/
>
> Maybe something like this would make the behavior a bit clearer:
>
>   ...and returns a new string containing the expansion, also advancing
>   'str' to point to the next character after... (note that this function does
>   a recursive expansion) ...


Is this OK?

/*
 * Expand a string that follows '$'
 *
 * For example, if the input string is
 * ($(FOO)$($(BAR)))$(BAZ)
 * this helper evaluates
 * $($(FOO)$($(BAR)))
 * and returns a new string containing the expansion (note that the string is
 * recursively expanded), also advancing 'str' to point to the next character
 * after the corresponding closing parenthesis, in this case, *str will be
 * $(BAR)
 */



>> + * character after the corresponding closing parenthesis, in this case, *str
>> + * will be
>> + * $(BAR)
>> + */
>> +char *expand_dollar(const char **str)
>> +{
>> +   const char *p = *str;
>> +   const char *q;
>> +   char *tmp, *out;
>> +   int nest = 0;
>> +
>> +   /* '$$' represents an escaped '$' */
>> +   if (*p == '$') {
>> +   *str = p + 1;
>> +   return xstrdup("$");
>> +   }
>> +
>> +   /*
>> +* Kconfig does not support single-letter variable as in $A
>> +* or curly braces as in ${CC}.
>> +*/
>> +   if (*p != '(')
>> +   pperror("syntax error: '$' not followed by '('", p);
>
> Could say "not followed by '(' by or '$'".

Will do.


>> +
>> +   p++;
>> +   q = p;
>> +   while (*q) {
>> +   if (*q == '(') {
>> +   nest++;
>> +   } else if (*q == ')') {
>> +   if (nest-- == 0)
>> +   break;
>> +   }
>> +   q++;
>> +   }
>> +
>> +   if (!*q)
>> +   pperror("unterminated reference to '%s': missing ')'", p);
>> +
>> +   tmp = xmalloc(q - p + 1);
>> +   memcpy(tmp, p, q - p);
>> +   tmp[q - p] = 0;
>> +   *str = q + 1;
>> +   out = eval_clause(tmp);
>> +   free(tmp);
>> +
>> +   return out;
>
> This might be a bit clearer, since the 'str' update and the expansion
> are independent:

Indeed, will do.

>
>   /* Advance 'str' to after the expanded initial portion of the string */
>   *str = q + 1;
>
>   /* Save the "FOO" part of "(FOO)" into 'tmp' and expand it recursively */
>   tmp = xmalloc(q - p + 1);
>   memcpy(tmp, p, q - p);
>   tmp[q - p] = '\0';
>   out = eval_clause(tmp);
>   free(tmp);
>
>   return out;
>
> ...or switched around, but thought putting the 'str' bit first might
> emphasize that it isn't modified.


I prefer advancing the pointer at last.




>> +}
>> +
>> +/*
>> + * Expand variables in the given string.  Undefined variables
>> + * expand to an empty string.
>
> I wonder what the tradeoffs are vs. erroring out here (or leaving
> undefined variables as-is).


I want to stick to the Make-like behavior here and exploit it in some cases.
We can set some variables in some arch/*/Kconfig,
but unset in the others.




In some arch/*/Kconfig:

min-gcc-version := 40900




In init/Kconfig:

# GCC 4.5 is required to build Linux Kernel.
# Some architectures may override it (from arch/*/Kconfig) for their
requirement.
min-gcc-version := $(if,$(min-gcc-version),$(min-gcc-version),40500)

... check the gcc version, 

Re: [PATCH v4 03/31] kconfig: reference environment variables directly and remove 'option env='

2018-05-20 Thread Masahiro Yamada
Hi.



2018-05-21 0:46 GMT+09:00 Ulf Magnusson :

> s/environments/environment variables/

Will fix.


>
>> +* They will be written out to include/config/auto.conf.cmd
>> +*/
>> +   env_add(name, value);
>> +
>> +   return xstrdup(value);
>> +}
>> +
>> +void env_write_dep(FILE *f, const char *autoconfig_name)
>> +{
>> +   struct env *e, *tmp;
>> +
>> +   list_for_each_entry_safe(e, tmp, _list, node) {
>> +   fprintf(f, "ifneq \"$(%s)\" \"%s\"\n", e->name, e->value);
>> +   fprintf(f, "%s: FORCE\n", autoconfig_name);
>> +   fprintf(f, "endif\n");
>> +   env_del(e);
>> +   }
>> +}
>> +
>> +static char *eval_clause(const char *in)
>> +{
>> +   char *res, *name;
>> +
>> +   /*
>> +* Returns an empty string because '$()' should be evaluated
>> +* to a null string.
>> +*/
>
> Do you know of cases where this is more useful than erroring out?
>
> Not saying it doesn't make sense. Just curious.


I just followed how Make works.

Anyway, eval_clause() will return null string for null input.
I will remove that hunk.




>> +   if (!*in)
>> +   return xstrdup("");
>> +
>> +   name = expand_string(in);
>> +
>> +   res = env_expand(name);
>> +   free(name);
>> +
>> +   return res;
>> +}
>> +
>> +/*
>> + * Expand a string that follows '$'
>> + *
>> + * For example, if the input string is
>> + * ($(FOO)$($(BAR)))$(BAZ)
>> + * this helper evaluates
>> + * $($(FOO)$($(BAR)))
>> + * and returns the resulted string, then updates 'str' to point to the next
>
> s/resulted/resulting/
>
> Maybe something like this would make the behavior a bit clearer:
>
>   ...and returns a new string containing the expansion, also advancing
>   'str' to point to the next character after... (note that this function does
>   a recursive expansion) ...


Is this OK?

/*
 * Expand a string that follows '$'
 *
 * For example, if the input string is
 * ($(FOO)$($(BAR)))$(BAZ)
 * this helper evaluates
 * $($(FOO)$($(BAR)))
 * and returns a new string containing the expansion (note that the string is
 * recursively expanded), also advancing 'str' to point to the next character
 * after the corresponding closing parenthesis, in this case, *str will be
 * $(BAR)
 */



>> + * character after the corresponding closing parenthesis, in this case, *str
>> + * will be
>> + * $(BAR)
>> + */
>> +char *expand_dollar(const char **str)
>> +{
>> +   const char *p = *str;
>> +   const char *q;
>> +   char *tmp, *out;
>> +   int nest = 0;
>> +
>> +   /* '$$' represents an escaped '$' */
>> +   if (*p == '$') {
>> +   *str = p + 1;
>> +   return xstrdup("$");
>> +   }
>> +
>> +   /*
>> +* Kconfig does not support single-letter variable as in $A
>> +* or curly braces as in ${CC}.
>> +*/
>> +   if (*p != '(')
>> +   pperror("syntax error: '$' not followed by '('", p);
>
> Could say "not followed by '(' by or '$'".

Will do.


>> +
>> +   p++;
>> +   q = p;
>> +   while (*q) {
>> +   if (*q == '(') {
>> +   nest++;
>> +   } else if (*q == ')') {
>> +   if (nest-- == 0)
>> +   break;
>> +   }
>> +   q++;
>> +   }
>> +
>> +   if (!*q)
>> +   pperror("unterminated reference to '%s': missing ')'", p);
>> +
>> +   tmp = xmalloc(q - p + 1);
>> +   memcpy(tmp, p, q - p);
>> +   tmp[q - p] = 0;
>> +   *str = q + 1;
>> +   out = eval_clause(tmp);
>> +   free(tmp);
>> +
>> +   return out;
>
> This might be a bit clearer, since the 'str' update and the expansion
> are independent:

Indeed, will do.

>
>   /* Advance 'str' to after the expanded initial portion of the string */
>   *str = q + 1;
>
>   /* Save the "FOO" part of "(FOO)" into 'tmp' and expand it recursively */
>   tmp = xmalloc(q - p + 1);
>   memcpy(tmp, p, q - p);
>   tmp[q - p] = '\0';
>   out = eval_clause(tmp);
>   free(tmp);
>
>   return out;
>
> ...or switched around, but thought putting the 'str' bit first might
> emphasize that it isn't modified.


I prefer advancing the pointer at last.




>> +}
>> +
>> +/*
>> + * Expand variables in the given string.  Undefined variables
>> + * expand to an empty string.
>
> I wonder what the tradeoffs are vs. erroring out here (or leaving
> undefined variables as-is).


I want to stick to the Make-like behavior here and exploit it in some cases.
We can set some variables in some arch/*/Kconfig,
but unset in the others.




In some arch/*/Kconfig:

min-gcc-version := 40900




In init/Kconfig:

# GCC 4.5 is required to build Linux Kernel.
# Some architectures may override it (from arch/*/Kconfig) for their
requirement.
min-gcc-version := $(if,$(min-gcc-version),$(min-gcc-version),40500)

... check the gcc version, then show error
if it is 

[PATCH 07/30] staging: lustre: simplify capability dropping.

2018-05-20 Thread NeilBrown
Lustre has a 'squash credentials' concept similar to the "anon_uid"
for nfsd.  When accessing a file with squashed credentials, we
need to also drop capabilities.
Linux has cap_drop_fs_set() and cap_drop_nfsd_set().  Rather than
taking a completely different approach, this patch changes lustre
to use this same cap_drop_*_set() approach.

With this change we also drop CAP_MKNOD and CAP_MAC_OVERRIDE
which are probably appropriate, and don't drop
CAP_SYS_ADMIN or CAP_SYS_BOOT which should be irrelevant for
file permission checking

Calling both cap_drop_*_set() seems a bit clumsy, but gets
the job done.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |   10 --
 drivers/staging/lustre/lustre/llite/file.c |8 +++-
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h 
b/drivers/staging/lustre/include/linux/libcfs/curproc.h
index 83526f84495d..fc6f6eb2d5fe 100644
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
@@ -50,16 +50,6 @@
 
 typedef u32 cfs_cap_t;
 
-#define CFS_CAP_FS_MASK (BIT(CAP_CHOWN) |  \
-BIT(CAP_DAC_OVERRIDE) |\
-BIT(CAP_DAC_READ_SEARCH) | \
-BIT(CAP_FOWNER) |  \
-BIT(CAP_FSETID) |  \
-BIT(CAP_LINUX_IMMUTABLE) | \
-BIT(CAP_SYS_ADMIN) |   \
-BIT(CAP_SYS_BOOT) |\
-BIT(CAP_SYS_RESOURCE))
-
 static inline cfs_cap_t cfs_curproc_cap_pack(void)
 {
/* cfs_cap_t is only the first word of kernel_cap_t */
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index 0026fde81ad3..a77cadcd9d48 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -3050,7 +3050,6 @@ int ll_inode_permission(struct inode *inode, int mask)
const struct cred *old_cred = NULL;
struct cred *cred = NULL;
bool squash_id = false;
-   cfs_cap_t cap;
int rc = 0;
 
if (mask & MAY_NOT_BLOCK)
@@ -3094,10 +3093,9 @@ int ll_inode_permission(struct inode *inode, int mask)
 
cred->fsuid = make_kuid(_user_ns, squash->rsi_uid);
cred->fsgid = make_kgid(_user_ns, squash->rsi_gid);
-   for (cap = 0; cap < sizeof(cfs_cap_t) * 8; cap++) {
-   if ((1 << cap) & CFS_CAP_FS_MASK)
-   cap_lower(cred->cap_effective, cap);
-   }
+   cred->cap_effective = cap_drop_nfsd_set(cred->cap_effective);
+   cred->cap_effective = cap_drop_fs_set(cred->cap_effective);
+
old_cred = override_creds(cred);
}
 




[PATCH 07/30] staging: lustre: simplify capability dropping.

2018-05-20 Thread NeilBrown
Lustre has a 'squash credentials' concept similar to the "anon_uid"
for nfsd.  When accessing a file with squashed credentials, we
need to also drop capabilities.
Linux has cap_drop_fs_set() and cap_drop_nfsd_set().  Rather than
taking a completely different approach, this patch changes lustre
to use this same cap_drop_*_set() approach.

With this change we also drop CAP_MKNOD and CAP_MAC_OVERRIDE
which are probably appropriate, and don't drop
CAP_SYS_ADMIN or CAP_SYS_BOOT which should be irrelevant for
file permission checking

Calling both cap_drop_*_set() seems a bit clumsy, but gets
the job done.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |   10 --
 drivers/staging/lustre/lustre/llite/file.c |8 +++-
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h 
b/drivers/staging/lustre/include/linux/libcfs/curproc.h
index 83526f84495d..fc6f6eb2d5fe 100644
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
@@ -50,16 +50,6 @@
 
 typedef u32 cfs_cap_t;
 
-#define CFS_CAP_FS_MASK (BIT(CAP_CHOWN) |  \
-BIT(CAP_DAC_OVERRIDE) |\
-BIT(CAP_DAC_READ_SEARCH) | \
-BIT(CAP_FOWNER) |  \
-BIT(CAP_FSETID) |  \
-BIT(CAP_LINUX_IMMUTABLE) | \
-BIT(CAP_SYS_ADMIN) |   \
-BIT(CAP_SYS_BOOT) |\
-BIT(CAP_SYS_RESOURCE))
-
 static inline cfs_cap_t cfs_curproc_cap_pack(void)
 {
/* cfs_cap_t is only the first word of kernel_cap_t */
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index 0026fde81ad3..a77cadcd9d48 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -3050,7 +3050,6 @@ int ll_inode_permission(struct inode *inode, int mask)
const struct cred *old_cred = NULL;
struct cred *cred = NULL;
bool squash_id = false;
-   cfs_cap_t cap;
int rc = 0;
 
if (mask & MAY_NOT_BLOCK)
@@ -3094,10 +3093,9 @@ int ll_inode_permission(struct inode *inode, int mask)
 
cred->fsuid = make_kuid(_user_ns, squash->rsi_uid);
cred->fsgid = make_kgid(_user_ns, squash->rsi_gid);
-   for (cap = 0; cap < sizeof(cfs_cap_t) * 8; cap++) {
-   if ((1 << cap) & CFS_CAP_FS_MASK)
-   cap_lower(cred->cap_effective, cap);
-   }
+   cred->cap_effective = cap_drop_nfsd_set(cred->cap_effective);
+   cred->cap_effective = cap_drop_fs_set(cred->cap_effective);
+
old_cred = override_creds(cred);
}
 




Re: [PATCH v2 0/4] fixes, cleanups for rcu/dev

2018-05-20 Thread Joel Fernandes
On Sun, May 20, 2018 at 09:32:47PM -0700, Joel Fernandes wrote:
> Hi Paul,
> 
> Here are some patches reworked with a few comments on few of the patches
> from previous series: https://lkml.org/lkml/2018/5/13/296
> 
> 4/4 is a new addition which fixes a potential issue.
> 
> Let me know what you think, thanks!
> 
> Joel Fernandes (4):
>   rcu: Add comment documenting how rcu_seq_snap works
>   rcu: Cleanup the variables used to request a new grace period
>   rcu: Use better variable names in funnel locking loop
>   rcu: Unlock non-start node only after accessing its gp_seq_needed

Please disregard the v2, my infant daughter distracted me when I was
preparing the 'git format-patch' :-) I was not supposed to send the 'Speed
up..' patch since I already sent that separately. And patch 4/4 which I
believe fixes a potential issue is also missing. So lets drop/ignore all of
this v2 and I'll just send a v3.

thanks!
 


Re: [PATCH v2 0/4] fixes, cleanups for rcu/dev

2018-05-20 Thread Joel Fernandes
On Sun, May 20, 2018 at 09:32:47PM -0700, Joel Fernandes wrote:
> Hi Paul,
> 
> Here are some patches reworked with a few comments on few of the patches
> from previous series: https://lkml.org/lkml/2018/5/13/296
> 
> 4/4 is a new addition which fixes a potential issue.
> 
> Let me know what you think, thanks!
> 
> Joel Fernandes (4):
>   rcu: Add comment documenting how rcu_seq_snap works
>   rcu: Cleanup the variables used to request a new grace period
>   rcu: Use better variable names in funnel locking loop
>   rcu: Unlock non-start node only after accessing its gp_seq_needed

Please disregard the v2, my infant daughter distracted me when I was
preparing the 'git format-patch' :-) I was not supposed to send the 'Speed
up..' patch since I already sent that separately. And patch 4/4 which I
believe fixes a potential issue is also missing. So lets drop/ignore all of
this v2 and I'll just send a v3.

thanks!
 


[PATCH v3 0/4] fixes, cleanups for rcu/dev

2018-05-20 Thread Joel Fernandes
Hi Paul,

Here are some patches reworked with a few comments on few of the patches
from previous series: https://lkml.org/lkml/2018/5/13/296

4/4 is a new addition which fixes a potential issue.

Please disregard the v2, and consider this v3 instead, since that v2 was
a pure patch generation mess. thanks!

Joel Fernandes (4):
  rcu: Add comment documenting how rcu_seq_snap works
  rcu: Cleanup the variables used to request a new grace period
  rcu: Use better variable names in funnel locking loop
  rcu: Unlock non-start node only after accessing its gp_seq_needed

 include/trace/events/rcu.h | 15 +++
 kernel/rcu/rcu.h   | 33 +++-
 kernel/rcu/tree.c  | 80 +-
 3 files changed, 85 insertions(+), 43 deletions(-)

-- 
2.17.0.441.gb46fe60e1d-goog



[PATCH v3 0/4] fixes, cleanups for rcu/dev

2018-05-20 Thread Joel Fernandes
Hi Paul,

Here are some patches reworked with a few comments on few of the patches
from previous series: https://lkml.org/lkml/2018/5/13/296

4/4 is a new addition which fixes a potential issue.

Please disregard the v2, and consider this v3 instead, since that v2 was
a pure patch generation mess. thanks!

Joel Fernandes (4):
  rcu: Add comment documenting how rcu_seq_snap works
  rcu: Cleanup the variables used to request a new grace period
  rcu: Use better variable names in funnel locking loop
  rcu: Unlock non-start node only after accessing its gp_seq_needed

 include/trace/events/rcu.h | 15 +++
 kernel/rcu/rcu.h   | 33 +++-
 kernel/rcu/tree.c  | 80 +-
 3 files changed, 85 insertions(+), 43 deletions(-)

-- 
2.17.0.441.gb46fe60e1d-goog



[PATCH v3 3/4] rcu: Use better variable names in funnel locking loop

2018-05-20 Thread Joel Fernandes
The funnel locking loop in rcu_start_this_gp uses rcu_root as a
temporary variable while walking the combining tree. This causes a
tiresome exercise of a code reader reminding themselves that rcu_root
may not be root. Lets just call it rnp, and rename other variables as
well to be more appropriate.

Original patch: https://patchwork.kernel.org/patch/10396577/

Signed-off-by: Joel Fernandes 
---
 kernel/rcu/tree.c | 48 ---
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 0ffd41ba304f..879c67a31116 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1526,7 +1526,7 @@ static void trace_rcu_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
 
 /*
  * rcu_start_this_gp - Request the start of a particular grace period
- * @rnp: The leaf node of the CPU from which to start.
+ * @rnp_start: The leaf node of the CPU from which to start.
  * @rdp: The rcu_data corresponding to the CPU from which to start.
  * @gp_seq_req: The gp_seq of the grace period to start.
  *
@@ -1540,12 +1540,12 @@ static void trace_rcu_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
  *
  * Returns true if the GP thread needs to be awakened else false.
  */
-static bool rcu_start_this_gp(struct rcu_node *rnp, struct rcu_data *rdp,
+static bool rcu_start_this_gp(struct rcu_node *rnp_start, struct rcu_data *rdp,
  unsigned long gp_seq_req)
 {
bool ret = false;
struct rcu_state *rsp = rdp->rsp;
-   struct rcu_node *rnp_root;
+   struct rcu_node *rnp, *rnp_root = NULL;
 
/*
 * Use funnel locking to either acquire the root rcu_node
@@ -1556,34 +1556,36 @@ static bool rcu_start_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
 * scan the leaf rcu_node structures.  Note that rnp->lock must
 * not be released.
 */
-   raw_lockdep_assert_held_rcu_node(rnp);
-   trace_rcu_this_gp(rnp, rdp, gp_seq_req, TPS("Startleaf"));
-   for (rnp_root = rnp; 1; rnp_root = rnp_root->parent) {
-   if (rnp_root != rnp)
-   raw_spin_lock_rcu_node(rnp_root);
-   if (ULONG_CMP_GE(rnp_root->gp_seq_needed, gp_seq_req) ||
-   rcu_seq_started(_root->gp_seq, gp_seq_req) ||
-   (rnp != rnp_root &&
-rcu_seq_state(rcu_seq_current(_root->gp_seq {
-   trace_rcu_this_gp(rnp_root, rdp, gp_seq_req,
+   raw_lockdep_assert_held_rcu_node(rnp_start);
+   trace_rcu_this_gp(rnp_start, rdp, gp_seq_req, TPS("Startleaf"));
+   for (rnp = rnp_start; 1; rnp = rnp->parent) {
+   if (rnp != rnp_start)
+   raw_spin_lock_rcu_node(rnp);
+   if (ULONG_CMP_GE(rnp->gp_seq_needed, gp_seq_req) ||
+   rcu_seq_started(>gp_seq, gp_seq_req) ||
+   (rnp != rnp_start &&
+rcu_seq_state(rcu_seq_current(>gp_seq {
+   trace_rcu_this_gp(rnp, rdp, gp_seq_req,
  TPS("Prestarted"));
goto unlock_out;
}
-   rnp_root->gp_seq_needed = gp_seq_req;
-   if (rcu_seq_state(rcu_seq_current(>gp_seq))) {
+   rnp->gp_seq_needed = gp_seq_req;
+   if (rcu_seq_state(rcu_seq_current(_start->gp_seq))) {
/*
 * We just marked the leaf, and a grace period
 * is in progress, which means that rcu_gp_cleanup()
 * will see the marking.  Bail to reduce contention.
 */
-   trace_rcu_this_gp(rnp, rdp, gp_seq_req,
+   trace_rcu_this_gp(rnp_start, rdp, gp_seq_req,
  TPS("Startedleaf"));
goto unlock_out;
}
-   if (rnp_root != rnp && rnp_root->parent != NULL)
-   raw_spin_unlock_rcu_node(rnp_root);
-   if (!rnp_root->parent)
+   if (rnp != rnp_start && rnp->parent != NULL)
+   raw_spin_unlock_rcu_node(rnp);
+   if (!rnp->parent) {
+   rnp_root = rnp;
break;  /* At root, and perhaps also leaf. */
+   }
}
 
/* If GP already in progress, just leave, otherwise start one. */
@@ -1601,11 +1603,11 @@ static bool rcu_start_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
trace_rcu_grace_period(rsp->name, READ_ONCE(rsp->gp_seq), 
TPS("newreq"));
ret = true;  /* Caller must wake GP kthread. */
 unlock_out:
-   if (rnp != rnp_root)
-   raw_spin_unlock_rcu_node(rnp_root);
+   if (rnp != rnp_start)
+   raw_spin_unlock_rcu_node(rnp);
/* Push furthest requested GP to leaf node and rcu_data 

[PATCH v3 3/4] rcu: Use better variable names in funnel locking loop

2018-05-20 Thread Joel Fernandes
The funnel locking loop in rcu_start_this_gp uses rcu_root as a
temporary variable while walking the combining tree. This causes a
tiresome exercise of a code reader reminding themselves that rcu_root
may not be root. Lets just call it rnp, and rename other variables as
well to be more appropriate.

Original patch: https://patchwork.kernel.org/patch/10396577/

Signed-off-by: Joel Fernandes 
---
 kernel/rcu/tree.c | 48 ---
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 0ffd41ba304f..879c67a31116 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1526,7 +1526,7 @@ static void trace_rcu_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
 
 /*
  * rcu_start_this_gp - Request the start of a particular grace period
- * @rnp: The leaf node of the CPU from which to start.
+ * @rnp_start: The leaf node of the CPU from which to start.
  * @rdp: The rcu_data corresponding to the CPU from which to start.
  * @gp_seq_req: The gp_seq of the grace period to start.
  *
@@ -1540,12 +1540,12 @@ static void trace_rcu_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
  *
  * Returns true if the GP thread needs to be awakened else false.
  */
-static bool rcu_start_this_gp(struct rcu_node *rnp, struct rcu_data *rdp,
+static bool rcu_start_this_gp(struct rcu_node *rnp_start, struct rcu_data *rdp,
  unsigned long gp_seq_req)
 {
bool ret = false;
struct rcu_state *rsp = rdp->rsp;
-   struct rcu_node *rnp_root;
+   struct rcu_node *rnp, *rnp_root = NULL;
 
/*
 * Use funnel locking to either acquire the root rcu_node
@@ -1556,34 +1556,36 @@ static bool rcu_start_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
 * scan the leaf rcu_node structures.  Note that rnp->lock must
 * not be released.
 */
-   raw_lockdep_assert_held_rcu_node(rnp);
-   trace_rcu_this_gp(rnp, rdp, gp_seq_req, TPS("Startleaf"));
-   for (rnp_root = rnp; 1; rnp_root = rnp_root->parent) {
-   if (rnp_root != rnp)
-   raw_spin_lock_rcu_node(rnp_root);
-   if (ULONG_CMP_GE(rnp_root->gp_seq_needed, gp_seq_req) ||
-   rcu_seq_started(_root->gp_seq, gp_seq_req) ||
-   (rnp != rnp_root &&
-rcu_seq_state(rcu_seq_current(_root->gp_seq {
-   trace_rcu_this_gp(rnp_root, rdp, gp_seq_req,
+   raw_lockdep_assert_held_rcu_node(rnp_start);
+   trace_rcu_this_gp(rnp_start, rdp, gp_seq_req, TPS("Startleaf"));
+   for (rnp = rnp_start; 1; rnp = rnp->parent) {
+   if (rnp != rnp_start)
+   raw_spin_lock_rcu_node(rnp);
+   if (ULONG_CMP_GE(rnp->gp_seq_needed, gp_seq_req) ||
+   rcu_seq_started(>gp_seq, gp_seq_req) ||
+   (rnp != rnp_start &&
+rcu_seq_state(rcu_seq_current(>gp_seq {
+   trace_rcu_this_gp(rnp, rdp, gp_seq_req,
  TPS("Prestarted"));
goto unlock_out;
}
-   rnp_root->gp_seq_needed = gp_seq_req;
-   if (rcu_seq_state(rcu_seq_current(>gp_seq))) {
+   rnp->gp_seq_needed = gp_seq_req;
+   if (rcu_seq_state(rcu_seq_current(_start->gp_seq))) {
/*
 * We just marked the leaf, and a grace period
 * is in progress, which means that rcu_gp_cleanup()
 * will see the marking.  Bail to reduce contention.
 */
-   trace_rcu_this_gp(rnp, rdp, gp_seq_req,
+   trace_rcu_this_gp(rnp_start, rdp, gp_seq_req,
  TPS("Startedleaf"));
goto unlock_out;
}
-   if (rnp_root != rnp && rnp_root->parent != NULL)
-   raw_spin_unlock_rcu_node(rnp_root);
-   if (!rnp_root->parent)
+   if (rnp != rnp_start && rnp->parent != NULL)
+   raw_spin_unlock_rcu_node(rnp);
+   if (!rnp->parent) {
+   rnp_root = rnp;
break;  /* At root, and perhaps also leaf. */
+   }
}
 
/* If GP already in progress, just leave, otherwise start one. */
@@ -1601,11 +1603,11 @@ static bool rcu_start_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
trace_rcu_grace_period(rsp->name, READ_ONCE(rsp->gp_seq), 
TPS("newreq"));
ret = true;  /* Caller must wake GP kthread. */
 unlock_out:
-   if (rnp != rnp_root)
-   raw_spin_unlock_rcu_node(rnp_root);
+   if (rnp != rnp_start)
+   raw_spin_unlock_rcu_node(rnp);
/* Push furthest requested GP to leaf node and rcu_data structure. */
-   if 

[PATCH v3 2/4] rcu: Cleanup the variables used to request a new grace period

2018-05-20 Thread Joel Fernandes
The 'c' variable was used previously to store the grace period that is
being requested. However it is not very meaningful since the gp_seq
conversions. This patch replaces it with gp_seq_req indicating that
this is the grace period that was requested. Also updating tracing with
the new name.

Previous patch discussion is at:
https://patchwork.kernel.org/patch/10396579/

Signed-off-by: Joel Fernandes 
---
 include/trace/events/rcu.h | 15 ++--
 kernel/rcu/tree.c  | 50 ++
 2 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
index 5373bc61ae08..a8d07feff6a0 100644
--- a/include/trace/events/rcu.h
+++ b/include/trace/events/rcu.h
@@ -103,15 +103,16 @@ TRACE_EVENT(rcu_grace_period,
  */
 TRACE_EVENT(rcu_future_grace_period,
 
-   TP_PROTO(const char *rcuname, unsigned long gp_seq, unsigned long c,
-u8 level, int grplo, int grphi, const char *gpevent),
+   TP_PROTO(const char *rcuname, unsigned long gp_seq,
+unsigned long gp_seq_req, u8 level, int grplo, int grphi,
+const char *gpevent),
 
-   TP_ARGS(rcuname, gp_seq, c, level, grplo, grphi, gpevent),
+   TP_ARGS(rcuname, gp_seq, gp_seq_req, level, grplo, grphi, gpevent),
 
TP_STRUCT__entry(
__field(const char *, rcuname)
__field(unsigned long, gp_seq)
-   __field(unsigned long, c)
+   __field(unsigned long, gp_seq_req)
__field(u8, level)
__field(int, grplo)
__field(int, grphi)
@@ -121,7 +122,7 @@ TRACE_EVENT(rcu_future_grace_period,
TP_fast_assign(
__entry->rcuname = rcuname;
__entry->gp_seq = gp_seq;
-   __entry->c = c;
+   __entry->gp_seq_req = gp_seq_req;
__entry->level = level;
__entry->grplo = grplo;
__entry->grphi = grphi;
@@ -129,7 +130,7 @@ TRACE_EVENT(rcu_future_grace_period,
),
 
TP_printk("%s %lu %lu %u %d %d %s",
- __entry->rcuname, __entry->gp_seq, __entry->c, __entry->level,
+ __entry->rcuname, __entry->gp_seq, __entry->gp_seq_req, 
__entry->level,
  __entry->grplo, __entry->grphi, __entry->gpevent)
 );
 
@@ -751,7 +752,7 @@ TRACE_EVENT(rcu_barrier,
 #else /* #ifdef CONFIG_RCU_TRACE */
 
 #define trace_rcu_grace_period(rcuname, gp_seq, gpevent) do { } while (0)
-#define trace_rcu_future_grace_period(rcuname, gp_seq, c, \
+#define trace_rcu_future_grace_period(rcuname, gp_seq, gp_seq_req, \
  level, grplo, grphi, event) \
  do { } while (0)
 #define trace_rcu_grace_period_init(rcuname, gp_seq, level, grplo, grphi, \
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 2c06e1ab90cd..0ffd41ba304f 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1518,13 +1518,18 @@ void rcu_cpu_stall_reset(void)
 
 /* Trace-event wrapper function for trace_rcu_future_grace_period.  */
 static void trace_rcu_this_gp(struct rcu_node *rnp, struct rcu_data *rdp,
- unsigned long c, const char *s)
+ unsigned long gp_seq_req, const char *s)
 {
-   trace_rcu_future_grace_period(rdp->rsp->name, rnp->gp_seq, c,
+   trace_rcu_future_grace_period(rdp->rsp->name, rnp->gp_seq, gp_seq_req,
  rnp->level, rnp->grplo, rnp->grphi, s);
 }
 
 /*
+ * rcu_start_this_gp - Request the start of a particular grace period
+ * @rnp: The leaf node of the CPU from which to start.
+ * @rdp: The rcu_data corresponding to the CPU from which to start.
+ * @gp_seq_req: The gp_seq of the grace period to start.
+ *
  * Start the specified grace period, as needed to handle newly arrived
  * callbacks.  The required future grace periods are recorded in each
  * rcu_node structure's ->gp_seq_needed field.  Returns true if there
@@ -1532,9 +1537,11 @@ static void trace_rcu_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
  *
  * The caller must hold the specified rcu_node structure's ->lock, which
  * is why the caller is responsible for waking the grace-period kthread.
+ *
+ * Returns true if the GP thread needs to be awakened else false.
  */
 static bool rcu_start_this_gp(struct rcu_node *rnp, struct rcu_data *rdp,
- unsigned long c)
+ unsigned long gp_seq_req)
 {
bool ret = false;
struct rcu_state *rsp = rdp->rsp;
@@ -1550,25 +1557,27 @@ static bool rcu_start_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
 * not be released.
 */
raw_lockdep_assert_held_rcu_node(rnp);
-   trace_rcu_this_gp(rnp, rdp, c, TPS("Startleaf"));
+   trace_rcu_this_gp(rnp, rdp, gp_seq_req, TPS("Startleaf"));
for (rnp_root = rnp; 1; rnp_root = 

[PATCH v3 2/4] rcu: Cleanup the variables used to request a new grace period

2018-05-20 Thread Joel Fernandes
The 'c' variable was used previously to store the grace period that is
being requested. However it is not very meaningful since the gp_seq
conversions. This patch replaces it with gp_seq_req indicating that
this is the grace period that was requested. Also updating tracing with
the new name.

Previous patch discussion is at:
https://patchwork.kernel.org/patch/10396579/

Signed-off-by: Joel Fernandes 
---
 include/trace/events/rcu.h | 15 ++--
 kernel/rcu/tree.c  | 50 ++
 2 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
index 5373bc61ae08..a8d07feff6a0 100644
--- a/include/trace/events/rcu.h
+++ b/include/trace/events/rcu.h
@@ -103,15 +103,16 @@ TRACE_EVENT(rcu_grace_period,
  */
 TRACE_EVENT(rcu_future_grace_period,
 
-   TP_PROTO(const char *rcuname, unsigned long gp_seq, unsigned long c,
-u8 level, int grplo, int grphi, const char *gpevent),
+   TP_PROTO(const char *rcuname, unsigned long gp_seq,
+unsigned long gp_seq_req, u8 level, int grplo, int grphi,
+const char *gpevent),
 
-   TP_ARGS(rcuname, gp_seq, c, level, grplo, grphi, gpevent),
+   TP_ARGS(rcuname, gp_seq, gp_seq_req, level, grplo, grphi, gpevent),
 
TP_STRUCT__entry(
__field(const char *, rcuname)
__field(unsigned long, gp_seq)
-   __field(unsigned long, c)
+   __field(unsigned long, gp_seq_req)
__field(u8, level)
__field(int, grplo)
__field(int, grphi)
@@ -121,7 +122,7 @@ TRACE_EVENT(rcu_future_grace_period,
TP_fast_assign(
__entry->rcuname = rcuname;
__entry->gp_seq = gp_seq;
-   __entry->c = c;
+   __entry->gp_seq_req = gp_seq_req;
__entry->level = level;
__entry->grplo = grplo;
__entry->grphi = grphi;
@@ -129,7 +130,7 @@ TRACE_EVENT(rcu_future_grace_period,
),
 
TP_printk("%s %lu %lu %u %d %d %s",
- __entry->rcuname, __entry->gp_seq, __entry->c, __entry->level,
+ __entry->rcuname, __entry->gp_seq, __entry->gp_seq_req, 
__entry->level,
  __entry->grplo, __entry->grphi, __entry->gpevent)
 );
 
@@ -751,7 +752,7 @@ TRACE_EVENT(rcu_barrier,
 #else /* #ifdef CONFIG_RCU_TRACE */
 
 #define trace_rcu_grace_period(rcuname, gp_seq, gpevent) do { } while (0)
-#define trace_rcu_future_grace_period(rcuname, gp_seq, c, \
+#define trace_rcu_future_grace_period(rcuname, gp_seq, gp_seq_req, \
  level, grplo, grphi, event) \
  do { } while (0)
 #define trace_rcu_grace_period_init(rcuname, gp_seq, level, grplo, grphi, \
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 2c06e1ab90cd..0ffd41ba304f 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1518,13 +1518,18 @@ void rcu_cpu_stall_reset(void)
 
 /* Trace-event wrapper function for trace_rcu_future_grace_period.  */
 static void trace_rcu_this_gp(struct rcu_node *rnp, struct rcu_data *rdp,
- unsigned long c, const char *s)
+ unsigned long gp_seq_req, const char *s)
 {
-   trace_rcu_future_grace_period(rdp->rsp->name, rnp->gp_seq, c,
+   trace_rcu_future_grace_period(rdp->rsp->name, rnp->gp_seq, gp_seq_req,
  rnp->level, rnp->grplo, rnp->grphi, s);
 }
 
 /*
+ * rcu_start_this_gp - Request the start of a particular grace period
+ * @rnp: The leaf node of the CPU from which to start.
+ * @rdp: The rcu_data corresponding to the CPU from which to start.
+ * @gp_seq_req: The gp_seq of the grace period to start.
+ *
  * Start the specified grace period, as needed to handle newly arrived
  * callbacks.  The required future grace periods are recorded in each
  * rcu_node structure's ->gp_seq_needed field.  Returns true if there
@@ -1532,9 +1537,11 @@ static void trace_rcu_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
  *
  * The caller must hold the specified rcu_node structure's ->lock, which
  * is why the caller is responsible for waking the grace-period kthread.
+ *
+ * Returns true if the GP thread needs to be awakened else false.
  */
 static bool rcu_start_this_gp(struct rcu_node *rnp, struct rcu_data *rdp,
- unsigned long c)
+ unsigned long gp_seq_req)
 {
bool ret = false;
struct rcu_state *rsp = rdp->rsp;
@@ -1550,25 +1557,27 @@ static bool rcu_start_this_gp(struct rcu_node *rnp, 
struct rcu_data *rdp,
 * not be released.
 */
raw_lockdep_assert_held_rcu_node(rnp);
-   trace_rcu_this_gp(rnp, rdp, c, TPS("Startleaf"));
+   trace_rcu_this_gp(rnp, rdp, gp_seq_req, TPS("Startleaf"));
for (rnp_root = rnp; 1; rnp_root = rnp_root->parent) {

[PATCH v3 1/4] rcu: Add comment documenting how rcu_seq_snap works

2018-05-20 Thread Joel Fernandes
rcu_seq_snap may be tricky to decipher. Lets document how it works with
an example to make it easier.

Signed-off-by: Joel Fernandes (Google) 
---
 kernel/rcu/rcu.h | 33 -
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index 0453a7d12b3f..d4396c96f614 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -91,7 +91,38 @@ static inline void rcu_seq_end(unsigned long *sp)
WRITE_ONCE(*sp, rcu_seq_endval(sp));
 }
 
-/* Take a snapshot of the update side's sequence number. */
+/*
+ * rcu_seq_snap - Take a snapshot of the update side's sequence number.
+ *
+ * This function returns the earliest value of the grace-period sequence number
+ * that will indicate that a full grace period has elapsed since the current
+ * time.  Once the grace-period sequence number has reached this value, it will
+ * be safe to invoke all callbacks that have been registered prior to the
+ * current time. This value is the current grace-period number plus two to the
+ * power of the number of low-order bits reserved for state, then rounded up to
+ * the next value in which the state bits are all zero.
+ *
+ * For example, since RCU_SEQ_STATE_MASK=3 and the least significant bit of
+ * the seq is used to track if a GP is in progress or not, its sufficient if we
+ * add (6+1) and mask with ~3 to get the next GP. Let's see why with an 
example:
+ *
+ * Say the current seq is 12 which is 0b1100 (GP is 3 and state bits are 0b00).
+ * To get to the next GP number of 4, we have to add 0b100 to this (0x1 << 2)
+ * to account for the shift due to 2 state bits. Now, if the current seq is
+ * 13 (GP is 3 and state bits are 0b01), then it means the current grace period
+ * is already in progress so the next GP that a future call back will be queued
+ * to run at is GP+2 = 5, not 4. To account for the extra +1, we just overflow
+ * the 2 lower bits by adding 0b11. Incase the lower bit was set, the overflow
+ * will cause the extra +1 to the GP, along with the usual +1 explained before.
+ * This gives us GP+2. Finally we mask the lower to bits by ~0x3 incase the
+ * overflow didn't occur. This masking is needed because incase RCU was idle
+ * (no GP in progress so lower 2 bits are 0b00), then the overflow of the lower
+ * 2 state bits wouldn't occur, so we mask to zero out those lower 2 bits.
+ *
+ * In other words, the next seq can be obtained by (0b11 + 0b100) & (~0b11)
+ * which can be generalized to:
+ * seq + (RCU_SEQ_STATE_MASK + (RCU_SEQ_STATE_MASK + 1)) & 
(~RCU_SEQ_STATE_MASK)
+ */
 static inline unsigned long rcu_seq_snap(unsigned long *sp)
 {
unsigned long s;
-- 
2.17.0.441.gb46fe60e1d-goog



[PATCH v3 4/4] rcu: Unlock non-start node only after accessing its gp_seq_needed

2018-05-20 Thread Joel Fernandes
We acquire gp_seq_needed locklessly. To be safe, lets do the unlocking
after the access.

Signed-off-by: Joel Fernandes 
---
 kernel/rcu/tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 879c67a31116..efbd21b2a1a6 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1603,13 +1603,13 @@ static bool rcu_start_this_gp(struct rcu_node 
*rnp_start, struct rcu_data *rdp,
trace_rcu_grace_period(rsp->name, READ_ONCE(rsp->gp_seq), 
TPS("newreq"));
ret = true;  /* Caller must wake GP kthread. */
 unlock_out:
-   if (rnp != rnp_start)
-   raw_spin_unlock_rcu_node(rnp);
/* Push furthest requested GP to leaf node and rcu_data structure. */
if (ULONG_CMP_GE(rnp->gp_seq_needed, gp_seq_req)) {
rnp_start->gp_seq_needed = gp_seq_req;
rdp->gp_seq_needed = gp_seq_req;
}
+   if (rnp != rnp_start)
+   raw_spin_unlock_rcu_node(rnp);
return ret;
 }
 
-- 
2.17.0.441.gb46fe60e1d-goog



[PATCH v3 1/4] rcu: Add comment documenting how rcu_seq_snap works

2018-05-20 Thread Joel Fernandes
rcu_seq_snap may be tricky to decipher. Lets document how it works with
an example to make it easier.

Signed-off-by: Joel Fernandes (Google) 
---
 kernel/rcu/rcu.h | 33 -
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index 0453a7d12b3f..d4396c96f614 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -91,7 +91,38 @@ static inline void rcu_seq_end(unsigned long *sp)
WRITE_ONCE(*sp, rcu_seq_endval(sp));
 }
 
-/* Take a snapshot of the update side's sequence number. */
+/*
+ * rcu_seq_snap - Take a snapshot of the update side's sequence number.
+ *
+ * This function returns the earliest value of the grace-period sequence number
+ * that will indicate that a full grace period has elapsed since the current
+ * time.  Once the grace-period sequence number has reached this value, it will
+ * be safe to invoke all callbacks that have been registered prior to the
+ * current time. This value is the current grace-period number plus two to the
+ * power of the number of low-order bits reserved for state, then rounded up to
+ * the next value in which the state bits are all zero.
+ *
+ * For example, since RCU_SEQ_STATE_MASK=3 and the least significant bit of
+ * the seq is used to track if a GP is in progress or not, its sufficient if we
+ * add (6+1) and mask with ~3 to get the next GP. Let's see why with an 
example:
+ *
+ * Say the current seq is 12 which is 0b1100 (GP is 3 and state bits are 0b00).
+ * To get to the next GP number of 4, we have to add 0b100 to this (0x1 << 2)
+ * to account for the shift due to 2 state bits. Now, if the current seq is
+ * 13 (GP is 3 and state bits are 0b01), then it means the current grace period
+ * is already in progress so the next GP that a future call back will be queued
+ * to run at is GP+2 = 5, not 4. To account for the extra +1, we just overflow
+ * the 2 lower bits by adding 0b11. Incase the lower bit was set, the overflow
+ * will cause the extra +1 to the GP, along with the usual +1 explained before.
+ * This gives us GP+2. Finally we mask the lower to bits by ~0x3 incase the
+ * overflow didn't occur. This masking is needed because incase RCU was idle
+ * (no GP in progress so lower 2 bits are 0b00), then the overflow of the lower
+ * 2 state bits wouldn't occur, so we mask to zero out those lower 2 bits.
+ *
+ * In other words, the next seq can be obtained by (0b11 + 0b100) & (~0b11)
+ * which can be generalized to:
+ * seq + (RCU_SEQ_STATE_MASK + (RCU_SEQ_STATE_MASK + 1)) & 
(~RCU_SEQ_STATE_MASK)
+ */
 static inline unsigned long rcu_seq_snap(unsigned long *sp)
 {
unsigned long s;
-- 
2.17.0.441.gb46fe60e1d-goog



[PATCH v3 4/4] rcu: Unlock non-start node only after accessing its gp_seq_needed

2018-05-20 Thread Joel Fernandes
We acquire gp_seq_needed locklessly. To be safe, lets do the unlocking
after the access.

Signed-off-by: Joel Fernandes 
---
 kernel/rcu/tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 879c67a31116..efbd21b2a1a6 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1603,13 +1603,13 @@ static bool rcu_start_this_gp(struct rcu_node 
*rnp_start, struct rcu_data *rdp,
trace_rcu_grace_period(rsp->name, READ_ONCE(rsp->gp_seq), 
TPS("newreq"));
ret = true;  /* Caller must wake GP kthread. */
 unlock_out:
-   if (rnp != rnp_start)
-   raw_spin_unlock_rcu_node(rnp);
/* Push furthest requested GP to leaf node and rcu_data structure. */
if (ULONG_CMP_GE(rnp->gp_seq_needed, gp_seq_req)) {
rnp_start->gp_seq_needed = gp_seq_req;
rdp->gp_seq_needed = gp_seq_req;
}
+   if (rnp != rnp_start)
+   raw_spin_unlock_rcu_node(rnp);
return ret;
 }
 
-- 
2.17.0.441.gb46fe60e1d-goog



[PATCH 26/30] staging: lustre: remove libcfs_all from ptlrpc

2018-05-20 Thread NeilBrown
Some files didn't need it at all, others just needed
one or two includes.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/ptlrpc/errno.c   |1 -
 drivers/staging/lustre/lustre/ptlrpc/events.c  |2 +-
 drivers/staging/lustre/lustre/ptlrpc/llog_client.c |2 --
 drivers/staging/lustre/lustre/ptlrpc/llog_net.c|2 --
 drivers/staging/lustre/lustre/ptlrpc/nrs.c |3 ++-
 drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c|3 ++-
 .../staging/lustre/lustre/ptlrpc/pack_generic.c|2 --
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c |6 --
 drivers/staging/lustre/lustre/ptlrpc/recover.c |2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec.c |2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c|2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec_config.c  |2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec_gc.c  |2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c   |2 +-
 14 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c 
b/drivers/staging/lustre/lustre/ptlrpc/errno.c
index 9985e0bf4b87..c587fc86fcda 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/errno.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c
@@ -26,7 +26,6 @@
  * Copyright (c) 2013, Intel Corporation.
  */
 
-#include 
 #include 
 
 /*
diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c 
b/drivers/staging/lustre/lustre/ptlrpc/events.c
index d9d8d96f6605..130bacc2c891 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/events.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/events.c
@@ -33,7 +33,7 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
-#include 
+#include 
 # ifdef __mips64__
 #  include 
 # endif
diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c 
b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
index 3d8a2e5d2a92..946d538121de 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
@@ -39,8 +39,6 @@
 
 #define DEBUG_SUBSYSTEM S_LOG
 
-#include 
-
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c 
b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
index 3c6f2f171e41..b871d9e40a9e 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
@@ -43,8 +43,6 @@
 
 #define DEBUG_SUBSYSTEM S_LOG
 
-#include 
-
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c 
b/drivers/staging/lustre/lustre/ptlrpc/nrs.c
index 74a5fcf644e5..e09b86529c5d 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c
@@ -37,11 +37,12 @@
  */
 
 #define DEBUG_SUBSYSTEM S_RPC
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include "ptlrpc_internal.h"
 
 /**
diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c 
b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
index 4876d07aed7d..ff630d94dd26 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
@@ -44,9 +44,10 @@
  */
 
 #define DEBUG_SUBSYSTEM S_RPC
+#include 
+#include 
 #include 
 #include 
-#include 
 #include "ptlrpc_internal.h"
 
 /**
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c 
b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
index adf3b8c986e9..6ac9bb570663 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
@@ -41,8 +41,6 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
-#include 
-
 #include 
 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c 
b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
index bff14fb778d2..531005411edf 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
@@ -52,8 +52,10 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
-#include 
-
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c 
b/drivers/staging/lustre/lustre/ptlrpc/recover.c
index 004db1557a1a..2ea0a7ff87dd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/recover.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c
@@ -36,7 +36,7 @@
  */
 
 #define DEBUG_SUBSYSTEM S_RPC
-#include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 4af08b2492da..256421465bcd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -37,7 +37,7 @@
 
 #define DEBUG_SUBSYSTEM S_SEC
 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
index 1f35126124fc..625b9520d78f 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
+++ 

[PATCH 27/30] staging: lustre: remove libcfs_all.h from fid, fld, obdclass

2018-05-20 Thread NeilBrown
None of these files seem to nee libcfs_all.h

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/fid/fid_lib.c|1 -
 drivers/staging/lustre/lustre/fid/fid_request.c|1 -
 drivers/staging/lustre/lustre/fid/lproc_fid.c  |1 -
 drivers/staging/lustre/lustre/fld/fld_cache.c  |1 -
 drivers/staging/lustre/lustre/fld/fld_request.c|1 -
 drivers/staging/lustre/lustre/fld/lproc_fld.c  |1 -
 drivers/staging/lustre/lustre/obdclass/cl_object.c |1 -
 drivers/staging/lustre/lustre/obdclass/cl_page.c   |1 -
 .../lustre/lustre/obdclass/linux/linux-module.c|1 -
 drivers/staging/lustre/lustre/obdclass/lu_object.c |2 --
 drivers/staging/lustre/lustre/obdclass/lu_ref.c|2 --
 drivers/staging/lustre/lustre/obdclass/uuid.c  |2 --
 12 files changed, 15 deletions(-)

diff --git a/drivers/staging/lustre/lustre/fid/fid_lib.c 
b/drivers/staging/lustre/lustre/fid/fid_lib.c
index c2074beec5e9..ac52b378c155 100644
--- a/drivers/staging/lustre/lustre/fid/fid_lib.c
+++ b/drivers/staging/lustre/lustre/fid/fid_lib.c
@@ -40,7 +40,6 @@
 
 #define DEBUG_SUBSYSTEM S_FID
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c 
b/drivers/staging/lustre/lustre/fid/fid_request.c
index 693dc96f4175..c674652af03a 100644
--- a/drivers/staging/lustre/lustre/fid/fid_request.c
+++ b/drivers/staging/lustre/lustre/fid/fid_request.c
@@ -39,7 +39,6 @@
 
 #define DEBUG_SUBSYSTEM S_FID
 
-#include 
 #include 
 
 #include 
diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c 
b/drivers/staging/lustre/lustre/fid/lproc_fid.c
index 528b659cd9e8..0aabf473c9bd 100644
--- a/drivers/staging/lustre/lustre/fid/lproc_fid.c
+++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c
@@ -39,7 +39,6 @@
 
 #define DEBUG_SUBSYSTEM S_FID
 
-#include 
 #include 
 
 #include 
diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c 
b/drivers/staging/lustre/lustre/fld/fld_cache.c
index 63e6909a3edd..a7415c9a1c28 100644
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -40,7 +40,6 @@
 
 #define DEBUG_SUBSYSTEM S_FLD
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c 
b/drivers/staging/lustre/lustre/fld/fld_request.c
index 05ec4afa7513..7b7ba93a4db6 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -39,7 +39,6 @@
 
 #define DEBUG_SUBSYSTEM S_FLD
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c 
b/drivers/staging/lustre/lustre/fld/lproc_fld.c
index 49ea18d74cb2..0bcfb26ef8aa 100644
--- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -40,7 +40,6 @@
 
 #define DEBUG_SUBSYSTEM S_FLD
 
-#include 
 #include 
 
 #include 
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c 
b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index c42ddd50b6e3..42cce2dc5a45 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -47,7 +47,6 @@
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include 
 /* class_put_type() */
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c 
b/drivers/staging/lustre/lustre/obdclass/cl_page.c
index 0712d795788a..916cf81c5997 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_page.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c
@@ -38,7 +38,6 @@
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c 
b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
index 0a21a27c1a3a..d3196439985b 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
@@ -60,7 +60,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c 
b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 55efd704c9e8..8dd57eab57be 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -41,8 +41,6 @@
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include 
-
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c 
b/drivers/staging/lustre/lustre/obdclass/lu_ref.c
index bb90e6c0011c..f67cb89ea0ba 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_ref.c
@@ -39,8 +39,6 @@
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include 
-
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/obdclass/uuid.c 
b/drivers/staging/lustre/lustre/obdclass/uuid.c
index 8d14a0177a3f..ec8c6dc5c9a7 100644
--- a/drivers/staging/lustre/lustre/obdclass/uuid.c
+++ 

[PATCH 30/30] staging: lustre: remove libcfs_all.h

2018-05-20 Thread NeilBrown
In the remaining files that include libcfs_all.h,
replace it with other include files as necessary,
then remove libcfs_all.h

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_all.h   |   88 
 drivers/staging/lustre/lnet/libcfs/debug.c |5 +
 drivers/staging/lustre/lnet/libcfs/fail.c  |6 +
 drivers/staging/lustre/lnet/libcfs/hash.c  |5 +
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c|   15 ++-
 drivers/staging/lustre/lnet/libcfs/libcfs_lock.c   |5 +
 drivers/staging/lustre/lnet/libcfs/libcfs_mem.c|6 +
 drivers/staging/lustre/lnet/libcfs/libcfs_string.c |8 ++
 drivers/staging/lustre/lnet/libcfs/linux-crypto.c  |4 +
 drivers/staging/lustre/lnet/libcfs/linux-debug.c   |2 
 .../staging/lustre/lnet/libcfs/linux-tracefile.c   |3 -
 drivers/staging/lustre/lnet/libcfs/module.c|1 
 drivers/staging/lustre/lnet/libcfs/tracefile.c |   10 ++
 13 files changed, 50 insertions(+), 108 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_all.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_all.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_all.h
deleted file mode 100644
index c4232c823ac7..
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_all.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2015, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LIBCFS_LIBCFS_ALL_H__
-#define __LIBCFS_LIBCFS_ALL_H__
-
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-#include 
-#include 
-#include 
-
-#endif /* __LIBCFS_LIBCFS_ALL_H__ */
diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c 
b/drivers/staging/lustre/lnet/libcfs/debug.c
index d59b6243d6bd..06f694f6a28f 100644
--- a/drivers/staging/lustre/lnet/libcfs/debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/debug.c
@@ -38,7 +38,10 @@
 
 # define DEBUG_SUBSYSTEM S_LNET
 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include "tracefile.h"
 
 static char debug_file_name[1024];
diff --git a/drivers/staging/lustre/lnet/libcfs/fail.c 
b/drivers/staging/lustre/lnet/libcfs/fail.c
index 7385bdf541b6..bd86b3b5bc34 100644
--- a/drivers/staging/lustre/lnet/libcfs/fail.c
+++ b/drivers/staging/lustre/lnet/libcfs/fail.c
@@ -30,7 +30,11 @@
  * Lustre is a trademark of Oracle Corporation, Inc.
  */
 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 unsigned long cfs_fail_loc;
 EXPORT_SYMBOL(cfs_fail_loc);
diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c 
b/drivers/staging/lustre/lnet/libcfs/hash.c
index 88a853f64b89..48be66f0d654 100644
--- a/drivers/staging/lustre/lnet/libcfs/hash.c
+++ b/drivers/staging/lustre/lnet/libcfs/hash.c
@@ -105,8 +105,9 @@
  */
 #include 
 #include 
-
-#include 
+#include 
+#include 
+#include 
 
 #if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1
 static unsigned int warn_on_depth = 8;
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 0c9369e4a014..3d1cf457b286 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -31,16 +31,19 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
 
 /** Global CPU partition table */
 struct cfs_cpt_table   *cfs_cpt_tab __read_mostly;
 

[PATCH 26/30] staging: lustre: remove libcfs_all from ptlrpc

2018-05-20 Thread NeilBrown
Some files didn't need it at all, others just needed
one or two includes.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/ptlrpc/errno.c   |1 -
 drivers/staging/lustre/lustre/ptlrpc/events.c  |2 +-
 drivers/staging/lustre/lustre/ptlrpc/llog_client.c |2 --
 drivers/staging/lustre/lustre/ptlrpc/llog_net.c|2 --
 drivers/staging/lustre/lustre/ptlrpc/nrs.c |3 ++-
 drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c|3 ++-
 .../staging/lustre/lustre/ptlrpc/pack_generic.c|2 --
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c |6 --
 drivers/staging/lustre/lustre/ptlrpc/recover.c |2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec.c |2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c|2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec_config.c  |2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec_gc.c  |2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c   |2 +-
 14 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c 
b/drivers/staging/lustre/lustre/ptlrpc/errno.c
index 9985e0bf4b87..c587fc86fcda 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/errno.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c
@@ -26,7 +26,6 @@
  * Copyright (c) 2013, Intel Corporation.
  */
 
-#include 
 #include 
 
 /*
diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c 
b/drivers/staging/lustre/lustre/ptlrpc/events.c
index d9d8d96f6605..130bacc2c891 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/events.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/events.c
@@ -33,7 +33,7 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
-#include 
+#include 
 # ifdef __mips64__
 #  include 
 # endif
diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c 
b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
index 3d8a2e5d2a92..946d538121de 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
@@ -39,8 +39,6 @@
 
 #define DEBUG_SUBSYSTEM S_LOG
 
-#include 
-
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c 
b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
index 3c6f2f171e41..b871d9e40a9e 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c
@@ -43,8 +43,6 @@
 
 #define DEBUG_SUBSYSTEM S_LOG
 
-#include 
-
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c 
b/drivers/staging/lustre/lustre/ptlrpc/nrs.c
index 74a5fcf644e5..e09b86529c5d 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c
@@ -37,11 +37,12 @@
  */
 
 #define DEBUG_SUBSYSTEM S_RPC
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include "ptlrpc_internal.h"
 
 /**
diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c 
b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
index 4876d07aed7d..ff630d94dd26 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
@@ -44,9 +44,10 @@
  */
 
 #define DEBUG_SUBSYSTEM S_RPC
+#include 
+#include 
 #include 
 #include 
-#include 
 #include "ptlrpc_internal.h"
 
 /**
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c 
b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
index adf3b8c986e9..6ac9bb570663 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
@@ -41,8 +41,6 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
-#include 
-
 #include 
 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c 
b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
index bff14fb778d2..531005411edf 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
@@ -52,8 +52,10 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
-#include 
-
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c 
b/drivers/staging/lustre/lustre/ptlrpc/recover.c
index 004db1557a1a..2ea0a7ff87dd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/recover.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c
@@ -36,7 +36,7 @@
  */
 
 #define DEBUG_SUBSYSTEM S_RPC
-#include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 4af08b2492da..256421465bcd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -37,7 +37,7 @@
 
 #define DEBUG_SUBSYSTEM S_SEC
 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
index 1f35126124fc..625b9520d78f 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
+++ 

[PATCH 27/30] staging: lustre: remove libcfs_all.h from fid, fld, obdclass

2018-05-20 Thread NeilBrown
None of these files seem to nee libcfs_all.h

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/fid/fid_lib.c|1 -
 drivers/staging/lustre/lustre/fid/fid_request.c|1 -
 drivers/staging/lustre/lustre/fid/lproc_fid.c  |1 -
 drivers/staging/lustre/lustre/fld/fld_cache.c  |1 -
 drivers/staging/lustre/lustre/fld/fld_request.c|1 -
 drivers/staging/lustre/lustre/fld/lproc_fld.c  |1 -
 drivers/staging/lustre/lustre/obdclass/cl_object.c |1 -
 drivers/staging/lustre/lustre/obdclass/cl_page.c   |1 -
 .../lustre/lustre/obdclass/linux/linux-module.c|1 -
 drivers/staging/lustre/lustre/obdclass/lu_object.c |2 --
 drivers/staging/lustre/lustre/obdclass/lu_ref.c|2 --
 drivers/staging/lustre/lustre/obdclass/uuid.c  |2 --
 12 files changed, 15 deletions(-)

diff --git a/drivers/staging/lustre/lustre/fid/fid_lib.c 
b/drivers/staging/lustre/lustre/fid/fid_lib.c
index c2074beec5e9..ac52b378c155 100644
--- a/drivers/staging/lustre/lustre/fid/fid_lib.c
+++ b/drivers/staging/lustre/lustre/fid/fid_lib.c
@@ -40,7 +40,6 @@
 
 #define DEBUG_SUBSYSTEM S_FID
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c 
b/drivers/staging/lustre/lustre/fid/fid_request.c
index 693dc96f4175..c674652af03a 100644
--- a/drivers/staging/lustre/lustre/fid/fid_request.c
+++ b/drivers/staging/lustre/lustre/fid/fid_request.c
@@ -39,7 +39,6 @@
 
 #define DEBUG_SUBSYSTEM S_FID
 
-#include 
 #include 
 
 #include 
diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c 
b/drivers/staging/lustre/lustre/fid/lproc_fid.c
index 528b659cd9e8..0aabf473c9bd 100644
--- a/drivers/staging/lustre/lustre/fid/lproc_fid.c
+++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c
@@ -39,7 +39,6 @@
 
 #define DEBUG_SUBSYSTEM S_FID
 
-#include 
 #include 
 
 #include 
diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c 
b/drivers/staging/lustre/lustre/fld/fld_cache.c
index 63e6909a3edd..a7415c9a1c28 100644
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -40,7 +40,6 @@
 
 #define DEBUG_SUBSYSTEM S_FLD
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c 
b/drivers/staging/lustre/lustre/fld/fld_request.c
index 05ec4afa7513..7b7ba93a4db6 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -39,7 +39,6 @@
 
 #define DEBUG_SUBSYSTEM S_FLD
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c 
b/drivers/staging/lustre/lustre/fld/lproc_fld.c
index 49ea18d74cb2..0bcfb26ef8aa 100644
--- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -40,7 +40,6 @@
 
 #define DEBUG_SUBSYSTEM S_FLD
 
-#include 
 #include 
 
 #include 
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c 
b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index c42ddd50b6e3..42cce2dc5a45 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -47,7 +47,6 @@
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include 
 /* class_put_type() */
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c 
b/drivers/staging/lustre/lustre/obdclass/cl_page.c
index 0712d795788a..916cf81c5997 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_page.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c
@@ -38,7 +38,6 @@
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c 
b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
index 0a21a27c1a3a..d3196439985b 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
@@ -60,7 +60,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c 
b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 55efd704c9e8..8dd57eab57be 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -41,8 +41,6 @@
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include 
-
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c 
b/drivers/staging/lustre/lustre/obdclass/lu_ref.c
index bb90e6c0011c..f67cb89ea0ba 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_ref.c
@@ -39,8 +39,6 @@
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include 
-
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/obdclass/uuid.c 
b/drivers/staging/lustre/lustre/obdclass/uuid.c
index 8d14a0177a3f..ec8c6dc5c9a7 100644
--- a/drivers/staging/lustre/lustre/obdclass/uuid.c
+++ 

[PATCH 30/30] staging: lustre: remove libcfs_all.h

2018-05-20 Thread NeilBrown
In the remaining files that include libcfs_all.h,
replace it with other include files as necessary,
then remove libcfs_all.h

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_all.h   |   88 
 drivers/staging/lustre/lnet/libcfs/debug.c |5 +
 drivers/staging/lustre/lnet/libcfs/fail.c  |6 +
 drivers/staging/lustre/lnet/libcfs/hash.c  |5 +
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c|   15 ++-
 drivers/staging/lustre/lnet/libcfs/libcfs_lock.c   |5 +
 drivers/staging/lustre/lnet/libcfs/libcfs_mem.c|6 +
 drivers/staging/lustre/lnet/libcfs/libcfs_string.c |8 ++
 drivers/staging/lustre/lnet/libcfs/linux-crypto.c  |4 +
 drivers/staging/lustre/lnet/libcfs/linux-debug.c   |2 
 .../staging/lustre/lnet/libcfs/linux-tracefile.c   |3 -
 drivers/staging/lustre/lnet/libcfs/module.c|1 
 drivers/staging/lustre/lnet/libcfs/tracefile.c |   10 ++
 13 files changed, 50 insertions(+), 108 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_all.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_all.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_all.h
deleted file mode 100644
index c4232c823ac7..
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_all.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2015, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LIBCFS_LIBCFS_ALL_H__
-#define __LIBCFS_LIBCFS_ALL_H__
-
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-#include 
-#include 
-#include 
-
-#endif /* __LIBCFS_LIBCFS_ALL_H__ */
diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c 
b/drivers/staging/lustre/lnet/libcfs/debug.c
index d59b6243d6bd..06f694f6a28f 100644
--- a/drivers/staging/lustre/lnet/libcfs/debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/debug.c
@@ -38,7 +38,10 @@
 
 # define DEBUG_SUBSYSTEM S_LNET
 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include "tracefile.h"
 
 static char debug_file_name[1024];
diff --git a/drivers/staging/lustre/lnet/libcfs/fail.c 
b/drivers/staging/lustre/lnet/libcfs/fail.c
index 7385bdf541b6..bd86b3b5bc34 100644
--- a/drivers/staging/lustre/lnet/libcfs/fail.c
+++ b/drivers/staging/lustre/lnet/libcfs/fail.c
@@ -30,7 +30,11 @@
  * Lustre is a trademark of Oracle Corporation, Inc.
  */
 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 unsigned long cfs_fail_loc;
 EXPORT_SYMBOL(cfs_fail_loc);
diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c 
b/drivers/staging/lustre/lnet/libcfs/hash.c
index 88a853f64b89..48be66f0d654 100644
--- a/drivers/staging/lustre/lnet/libcfs/hash.c
+++ b/drivers/staging/lustre/lnet/libcfs/hash.c
@@ -105,8 +105,9 @@
  */
 #include 
 #include 
-
-#include 
+#include 
+#include 
+#include 
 
 #if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1
 static unsigned int warn_on_depth = 8;
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 0c9369e4a014..3d1cf457b286 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -31,16 +31,19 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
 
 /** Global CPU partition table */
 struct cfs_cpt_table   *cfs_cpt_tab __read_mostly;
 EXPORT_SYMBOL(cfs_cpt_tab);
-#define 

[PATCH 24/30] staging: lustre: remove libcfs_all.h from lustre/include/*.h

2018-05-20 Thread NeilBrown
Instead of the catch-all libcfs_all.h, just include the
files actually needed in different places.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_crypto.h|3 +++
 .../staging/lustre/lustre/include/lprocfs_status.h |2 +-
 drivers/staging/lustre/lustre/include/lu_object.h  |2 +-
 .../staging/lustre/lustre/include/lustre_compat.h  |1 +
 .../staging/lustre/lustre/include/lustre_disk.h|1 -
 drivers/staging/lustre/lustre/include/lustre_fid.h |2 +-
 drivers/staging/lustre/lustre/include/lustre_fld.h |1 -
 .../staging/lustre/lustre/include/lustre_handles.h |2 --
 .../staging/lustre/lustre/include/lustre_import.h  |1 +
 drivers/staging/lustre/lustre/include/lustre_lib.h |1 -
 drivers/staging/lustre/lustre/include/lustre_mdc.h |2 +-
 drivers/staging/lustre/lustre/include/lustre_mds.h |1 -
 drivers/staging/lustre/lustre/include/lustre_net.h |2 +-
 .../lustre/include/lustre_patchless_compat.h   |1 +
 drivers/staging/lustre/lustre/include/lustre_sec.h |2 ++
 drivers/staging/lustre/lustre/include/obd_cksum.h  |2 +-
 .../staging/lustre/lustre/include/obd_support.h|1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |1 +
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |1 +
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|2 ++
 drivers/staging/lustre/lustre/mdc/mdc_request.c|2 ++
 drivers/staging/lustre/lustre/obdclass/class_obd.c |2 ++
 .../staging/lustre/lustre/obdclass/kernelcomm.c|2 ++
 drivers/staging/lustre/lustre/obdclass/llog.c  |1 +
 .../lustre/lustre/obdclass/lprocfs_counters.c  |1 +
 .../lustre/lustre/obdclass/lustre_handles.c|1 +
 drivers/staging/lustre/lustre/obdclass/obd_mount.c |1 +
 drivers/staging/lustre/lustre/ptlrpc/client.c  |2 ++
 drivers/staging/lustre/lustre/ptlrpc/import.c  |1 +
 drivers/staging/lustre/lustre/ptlrpc/service.c |3 +++
 30 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
index 3a72117140ed..176fae7319e3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
@@ -29,6 +29,9 @@
 #ifndef _LIBCFS_CRYPTO_H
 #define _LIBCFS_CRYPTO_H
 
+#include 
+struct page;
+
 struct cfs_crypto_hash_type {
char*cht_name;  /*< hash algorithm name, equal to
 * format name for crypto api
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h 
b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 07b632dce2e3..1322ecffda13 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -43,8 +43,8 @@
 #include 
 #include 
 #include 
+#include 
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h 
b/drivers/staging/lustre/lustre/include/lu_object.h
index a1a75e026053..4153db762518 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -36,7 +36,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/include/lustre_compat.h 
b/drivers/staging/lustre/lustre/include/lustre_compat.h
index 9f488e605083..3c6db0d632dc 100644
--- a/drivers/staging/lustre/lustre/include/lustre_compat.h
+++ b/drivers/staging/lustre/lustre/include/lustre_compat.h
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h 
b/drivers/staging/lustre/lustre/include/lustre_disk.h
index c66c1b19f661..886e817644d6 100644
--- a/drivers/staging/lustre/lustre/include/lustre_disk.h
+++ b/drivers/staging/lustre/lustre/include/lustre_disk.h
@@ -48,7 +48,6 @@
 #include 
 #include 
 #include 
-#include 
 
 /** persistent mount data */
 
diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h 
b/drivers/staging/lustre/lustre/include/lustre_fid.h
index 9c4e14d88c46..094ad282de2c 100644
--- a/drivers/staging/lustre/lustre/include/lustre_fid.h
+++ b/drivers/staging/lustre/lustre/include/lustre_fid.h
@@ -149,7 +149,7 @@
  *  Even so, the MDT and OST resources are also in different LDLM namespaces.
  */
 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h 
b/drivers/staging/lustre/lustre/include/lustre_fld.h
index e90fd323db4a..f42122a4dfaa 100644
--- a/drivers/staging/lustre/lustre/include/lustre_fld.h
+++ b/drivers/staging/lustre/lustre/include/lustre_fld.h
@@ -40,7 +40,6 @@
  */
 
 #include 
-#include 
 #include 
 
 struct lu_client_fld;
diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h 

[PATCH 24/30] staging: lustre: remove libcfs_all.h from lustre/include/*.h

2018-05-20 Thread NeilBrown
Instead of the catch-all libcfs_all.h, just include the
files actually needed in different places.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_crypto.h|3 +++
 .../staging/lustre/lustre/include/lprocfs_status.h |2 +-
 drivers/staging/lustre/lustre/include/lu_object.h  |2 +-
 .../staging/lustre/lustre/include/lustre_compat.h  |1 +
 .../staging/lustre/lustre/include/lustre_disk.h|1 -
 drivers/staging/lustre/lustre/include/lustre_fid.h |2 +-
 drivers/staging/lustre/lustre/include/lustre_fld.h |1 -
 .../staging/lustre/lustre/include/lustre_handles.h |2 --
 .../staging/lustre/lustre/include/lustre_import.h  |1 +
 drivers/staging/lustre/lustre/include/lustre_lib.h |1 -
 drivers/staging/lustre/lustre/include/lustre_mdc.h |2 +-
 drivers/staging/lustre/lustre/include/lustre_mds.h |1 -
 drivers/staging/lustre/lustre/include/lustre_net.h |2 +-
 .../lustre/include/lustre_patchless_compat.h   |1 +
 drivers/staging/lustre/lustre/include/lustre_sec.h |2 ++
 drivers/staging/lustre/lustre/include/obd_cksum.h  |2 +-
 .../staging/lustre/lustre/include/obd_support.h|1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |1 +
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |1 +
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|2 ++
 drivers/staging/lustre/lustre/mdc/mdc_request.c|2 ++
 drivers/staging/lustre/lustre/obdclass/class_obd.c |2 ++
 .../staging/lustre/lustre/obdclass/kernelcomm.c|2 ++
 drivers/staging/lustre/lustre/obdclass/llog.c  |1 +
 .../lustre/lustre/obdclass/lprocfs_counters.c  |1 +
 .../lustre/lustre/obdclass/lustre_handles.c|1 +
 drivers/staging/lustre/lustre/obdclass/obd_mount.c |1 +
 drivers/staging/lustre/lustre/ptlrpc/client.c  |2 ++
 drivers/staging/lustre/lustre/ptlrpc/import.c  |1 +
 drivers/staging/lustre/lustre/ptlrpc/service.c |3 +++
 30 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
index 3a72117140ed..176fae7319e3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
@@ -29,6 +29,9 @@
 #ifndef _LIBCFS_CRYPTO_H
 #define _LIBCFS_CRYPTO_H
 
+#include 
+struct page;
+
 struct cfs_crypto_hash_type {
char*cht_name;  /*< hash algorithm name, equal to
 * format name for crypto api
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h 
b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 07b632dce2e3..1322ecffda13 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -43,8 +43,8 @@
 #include 
 #include 
 #include 
+#include 
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h 
b/drivers/staging/lustre/lustre/include/lu_object.h
index a1a75e026053..4153db762518 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -36,7 +36,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/include/lustre_compat.h 
b/drivers/staging/lustre/lustre/include/lustre_compat.h
index 9f488e605083..3c6db0d632dc 100644
--- a/drivers/staging/lustre/lustre/include/lustre_compat.h
+++ b/drivers/staging/lustre/lustre/include/lustre_compat.h
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h 
b/drivers/staging/lustre/lustre/include/lustre_disk.h
index c66c1b19f661..886e817644d6 100644
--- a/drivers/staging/lustre/lustre/include/lustre_disk.h
+++ b/drivers/staging/lustre/lustre/include/lustre_disk.h
@@ -48,7 +48,6 @@
 #include 
 #include 
 #include 
-#include 
 
 /** persistent mount data */
 
diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h 
b/drivers/staging/lustre/lustre/include/lustre_fid.h
index 9c4e14d88c46..094ad282de2c 100644
--- a/drivers/staging/lustre/lustre/include/lustre_fid.h
+++ b/drivers/staging/lustre/lustre/include/lustre_fid.h
@@ -149,7 +149,7 @@
  *  Even so, the MDT and OST resources are also in different LDLM namespaces.
  */
 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h 
b/drivers/staging/lustre/lustre/include/lustre_fld.h
index e90fd323db4a..f42122a4dfaa 100644
--- a/drivers/staging/lustre/lustre/include/lustre_fld.h
+++ b/drivers/staging/lustre/lustre/include/lustre_fld.h
@@ -40,7 +40,6 @@
  */
 
 #include 
-#include 
 #include 
 
 struct lu_client_fld;
diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h 

[PATCH 28/30] staging: lustre: remove remaining libcfs_all.h includes from lustre/lustre

2018-05-20 Thread NeilBrown
Most of these aren't needed, a few can be simplified.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/lustre/include/lustre_intent.h  |2 ++
 drivers/staging/lustre/lustre/ldlm/l_lock.c|1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c   |1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lib.c  |1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|2 +-
 drivers/staging/lustre/lustre/llite/glimpse.c  |1 -
 drivers/staging/lustre/lustre/llite/lcommon_cl.c   |1 -
 drivers/staging/lustre/lustre/llite/vvp_object.c   |2 --
 drivers/staging/lustre/lustre/lov/lov_ea.c |1 -
 drivers/staging/lustre/lustre/lov/lov_merge.c  |2 --
 drivers/staging/lustre/lustre/lov/lov_obd.c|1 -
 drivers/staging/lustre/lustre/lov/lov_offset.c |2 --
 drivers/staging/lustre/lustre/lov/lov_pool.c   |2 --
 drivers/staging/lustre/lustre/lov/lov_request.c|2 --
 .../staging/lustre/lustre/obdecho/echo_client.c|1 -
 drivers/staging/lustre/lustre/osc/osc_lock.c   |1 -
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +-
 18 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_intent.h 
b/drivers/staging/lustre/lustre/include/lustre_intent.h
index 519e94fc089d..51e5c0e03872 100644
--- a/drivers/staging/lustre/lustre/include/lustre_intent.h
+++ b/drivers/staging/lustre/lustre/include/lustre_intent.h
@@ -34,6 +34,8 @@
 #ifndef LUSTRE_INTENT_H
 #define LUSTRE_INTENT_H
 
+#include 
+
 /* intent IT_XXX are defined in lustre/include/obd.h */
 
 struct lookup_intent {
diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c 
b/drivers/staging/lustre/lustre/ldlm/l_lock.c
index fbeec219a75b..296259aa51e6 100644
--- a/drivers/staging/lustre/lustre/ldlm/l_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c
@@ -32,7 +32,6 @@
  */
 
 #define DEBUG_SUBSYSTEM S_LDLM
-#include 
 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index a6435cf8924a..4da23ade2bb3 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -47,7 +47,6 @@
  */
 
 #define DEBUG_SUBSYSTEM S_LDLM
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
index d8db751cf5a7..0aa4f234a4f4 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
@@ -40,7 +40,6 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 66702428a914..a644d133063b 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -38,7 +38,6 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index 7a1d18176032..b0a29f50c7d6 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -38,7 +38,7 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c 
b/drivers/staging/lustre/lustre/llite/glimpse.c
index eddab7d2887b..ce0d51767da3 100644
--- a/drivers/staging/lustre/lustre/llite/glimpse.c
+++ b/drivers/staging/lustre/lustre/llite/glimpse.c
@@ -37,7 +37,6 @@
  *   Author: Oleg Drokin 
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c 
b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
index de1de3b2dded..d7ea39ce0cb2 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
@@ -38,7 +38,6 @@
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c 
b/drivers/staging/lustre/lustre/llite/vvp_object.c
index 5aedbdbc75b7..b2cb51c8f7f4 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_object.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_object.c
@@ -37,8 +37,6 @@
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
-#include 
-
 #include 
 
 #include "llite_internal.h"
diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c 
b/drivers/staging/lustre/lustre/lov/lov_ea.c
index 223fb76c13aa..c80320ab0858 100644
--- a/drivers/staging/lustre/lustre/lov/lov_ea.c
+++ b/drivers/staging/lustre/lustre/lov/lov_ea.c
@@ -38,7 +38,6 @@
 #define DEBUG_SUBSYSTEM S_LOV
 
 #include 
-#include 
 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c 

[PATCH 25/30] staging: lustre: remove libcfs_all.h from remaining .h files.

2018-05-20 Thread NeilBrown
Now no *.h files include libcfs_all.h - only *.c files.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_hash.h  |3 +++
 drivers/staging/lustre/lustre/fid/fid_internal.h   |1 -
 drivers/staging/lustre/lustre/fld/fld_internal.h   |1 -
 drivers/staging/lustre/lustre/llite/llite_lib.c|1 +
 drivers/staging/lustre/lustre/llite/range_lock.c   |1 +
 drivers/staging/lustre/lustre/llite/range_lock.h   |2 +-
 drivers/staging/lustre/lustre/llite/vvp_dev.c  |1 +
 .../staging/lustre/lustre/lov/lov_cl_internal.h|2 --
 drivers/staging/lustre/lustre/mgc/mgc_internal.h   |1 -
 drivers/staging/lustre/lustre/mgc/mgc_request.c|1 +
 .../staging/lustre/lustre/osc/osc_cl_internal.h|2 --
 11 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
index 0506f1d45757..be315958a4b3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
@@ -40,6 +40,9 @@
 #define __LIBCFS_HASH_H__
 
 #include 
+#include 
+#include 
+#include 
 
 /*
  * Knuth recommends primes in approximately golden ratio to the maximum
diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h 
b/drivers/staging/lustre/lustre/fid/fid_internal.h
index 3d0003b2fb4b..14569e969a31 100644
--- a/drivers/staging/lustre/lustre/fid/fid_internal.h
+++ b/drivers/staging/lustre/lustre/fid/fid_internal.h
@@ -38,7 +38,6 @@
 #define __FID_INTERNAL_H
 
 #include 
-#include 
 
 /* Functions used internally in module. */
 
diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h 
b/drivers/staging/lustre/lustre/fld/fld_internal.h
index 9485c3d31559..e1d6aaa5c2b4 100644
--- a/drivers/staging/lustre/lustre/fld/fld_internal.h
+++ b/drivers/staging/lustre/lustre/fld/fld_internal.h
@@ -59,7 +59,6 @@
 
 #include 
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index bdb53ab77e58..7097361b3a1a 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/llite/range_lock.c 
b/drivers/staging/lustre/lustre/llite/range_lock.c
index cc9565f6bfe2..008a8874118d 100644
--- a/drivers/staging/lustre/lustre/llite/range_lock.c
+++ b/drivers/staging/lustre/lustre/llite/range_lock.c
@@ -36,6 +36,7 @@
  */
 #include "range_lock.h"
 #include 
+#include 
 
 /**
  * Initialize a range lock tree
diff --git a/drivers/staging/lustre/lustre/llite/range_lock.h 
b/drivers/staging/lustre/lustre/llite/range_lock.h
index 4af8781c71d7..9ebac09160f2 100644
--- a/drivers/staging/lustre/lustre/llite/range_lock.h
+++ b/drivers/staging/lustre/lustre/llite/range_lock.h
@@ -37,7 +37,7 @@
 #ifndef _RANGE_LOCK_H
 #define _RANGE_LOCK_H
 
-#include 
+#include 
 #include 
 
 struct range_lock {
diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c 
b/drivers/staging/lustre/lustre/llite/vvp_dev.c
index 8bda51fd97a2..31dc3c0ade01 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_dev.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c
@@ -38,6 +38,7 @@
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
+#include 
 #include 
 #include "llite_internal.h"
 #include "vvp_internal.h"
diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h 
b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
index d5849051319b..e4f762137a4a 100644
--- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
@@ -43,8 +43,6 @@
 #ifndef LOV_CL_INTERNAL_H
 #define LOV_CL_INTERNAL_H
 
-#include 
-
 #include 
 #include 
 #include "lov_internal.h"
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h 
b/drivers/staging/lustre/lustre/mgc/mgc_internal.h
index e402898cb28b..9541892b67c7 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h
+++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h
@@ -34,7 +34,6 @@
 #ifndef _MGC_INTERNAL_H
 #define _MGC_INTERNAL_H
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c 
b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 36c3f13ab9f4..32df804614d3 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -39,6 +39,7 @@
 #define D_MGC D_CONFIG /*|D_WARNING*/
 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h 
b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
index 29f318403328..2d3cba16ef34 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
@@ -43,8 +43,6 @@
 #ifndef OSC_CL_INTERNAL_H
 #define 

[PATCH 23/30] staging: lustre: remove libcfs_all.h from includes lustre/lnet

2018-05-20 Thread NeilBrown
Some of these include files didn't need to
include libcfs_all.h.  A couple did so replace with just the
base include files needed.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lnet/libcfs/tracefile.h  |8 +++-
 drivers/staging/lustre/lnet/selftest/conrpc.h   |1 -
 drivers/staging/lustre/lnet/selftest/console.h  |1 -
 drivers/staging/lustre/lnet/selftest/selftest.h |1 -
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h 
b/drivers/staging/lustre/lnet/libcfs/tracefile.h
index bbad0746f221..0608240d897f 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.h
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h
@@ -34,7 +34,13 @@
 #ifndef __LIBCFS_TRACEFILE_H__
 #define __LIBCFS_TRACEFILE_H__
 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 enum cfs_trace_buf_type {
CFS_TCD_TYPE_PROC = 0,
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.h 
b/drivers/staging/lustre/lnet/selftest/conrpc.h
index 29e743716bd6..ce2f92d04838 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.h
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.h
@@ -40,7 +40,6 @@
 #ifndef __LST_CONRPC_H__
 #define __LST_CONRPC_H__
 
-#include 
 #include 
 #include 
 #include "rpc.h"
diff --git a/drivers/staging/lustre/lnet/selftest/console.h 
b/drivers/staging/lustre/lnet/selftest/console.h
index 59e5ff9f6979..2826205e36a1 100644
--- a/drivers/staging/lustre/lnet/selftest/console.h
+++ b/drivers/staging/lustre/lnet/selftest/console.h
@@ -40,7 +40,6 @@
 #ifndef __LST_CONSOLE_H__
 #define __LST_CONSOLE_H__
 
-#include 
 #include 
 #include 
 #include "selftest.h"
diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h 
b/drivers/staging/lustre/lnet/selftest/selftest.h
index adf18515cb73..8737fa96b192 100644
--- a/drivers/staging/lustre/lnet/selftest/selftest.h
+++ b/drivers/staging/lustre/lnet/selftest/selftest.h
@@ -39,7 +39,6 @@
 
 #define LNET_ONLY
 
-#include 
 #include 
 #include 
 #include 




[PATCH 29/30] staging: lustre: move all libcfs_all includes except in lustre/lnet/libcfs/

2018-05-20 Thread NeilBrown
Again, most of these are not needed.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_string.h|2 ++
 drivers/staging/lustre/lnet/lnet/lib-socket.c  |1 -
 drivers/staging/lustre/lnet/lnet/nidstrings.c  |5 -
 drivers/staging/lustre/lnet/lnet/router_proc.c |1 -
 drivers/staging/lustre/lnet/selftest/conctl.c  |1 -
 drivers/staging/lustre/lnet/selftest/conrpc.c  |1 -
 drivers/staging/lustre/lnet/selftest/console.c |1 -
 7 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
index 66463477074a..cd7c3ccb2dc0 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
@@ -40,6 +40,8 @@
 #ifndef __LIBCFS_STRING_H__
 #define __LIBCFS_STRING_H__
 
+#include 
+
 /* libcfs_string.c */
 /* Convert a text string to a bitmask */
 int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c 
b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index b94896efc4c6..9b61260155f2 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -41,7 +41,6 @@
 #include 
 #include 
 
-#include 
 #include 
 
 static int
diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c 
b/drivers/staging/lustre/lnet/lnet/nidstrings.c
index 4c803ea88410..0f6c3fa16c65 100644
--- a/drivers/staging/lustre/lnet/lnet/nidstrings.c
+++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c
@@ -37,7 +37,10 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 
 /* max value for numeric network address */
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c 
b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 88ad787ff4ba..ae4b7f5953a0 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -20,7 +20,6 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include 
 #include 
 
 /*
diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c 
b/drivers/staging/lustre/lnet/selftest/conctl.c
index b4d521746541..906d82d90c0c 100644
--- a/drivers/staging/lustre/lnet/selftest/conctl.c
+++ b/drivers/staging/lustre/lnet/selftest/conctl.c
@@ -37,7 +37,6 @@
  * Author: Liang Zhen 
  */
 
-#include 
 #include 
 #include 
 #include "console.h"
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c 
b/drivers/staging/lustre/lnet/selftest/conrpc.c
index aefcf0db886e..0dabade3d091 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -37,7 +37,6 @@
  * Author: Liang Zhen 
  */
 
-#include 
 #include 
 #include "timer.h"
 #include "conrpc.h"
diff --git a/drivers/staging/lustre/lnet/selftest/console.c 
b/drivers/staging/lustre/lnet/selftest/console.c
index d11f854ea1f0..3c1c1b5997e0 100644
--- a/drivers/staging/lustre/lnet/selftest/console.c
+++ b/drivers/staging/lustre/lnet/selftest/console.c
@@ -37,7 +37,6 @@
  * Author: Liang Zhen 
  */
 
-#include 
 #include 
 #include "console.h"
 #include "conrpc.h"




[PATCH 25/30] staging: lustre: remove libcfs_all.h from remaining .h files.

2018-05-20 Thread NeilBrown
Now no *.h files include libcfs_all.h - only *.c files.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_hash.h  |3 +++
 drivers/staging/lustre/lustre/fid/fid_internal.h   |1 -
 drivers/staging/lustre/lustre/fld/fld_internal.h   |1 -
 drivers/staging/lustre/lustre/llite/llite_lib.c|1 +
 drivers/staging/lustre/lustre/llite/range_lock.c   |1 +
 drivers/staging/lustre/lustre/llite/range_lock.h   |2 +-
 drivers/staging/lustre/lustre/llite/vvp_dev.c  |1 +
 .../staging/lustre/lustre/lov/lov_cl_internal.h|2 --
 drivers/staging/lustre/lustre/mgc/mgc_internal.h   |1 -
 drivers/staging/lustre/lustre/mgc/mgc_request.c|1 +
 .../staging/lustre/lustre/osc/osc_cl_internal.h|2 --
 11 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
index 0506f1d45757..be315958a4b3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
@@ -40,6 +40,9 @@
 #define __LIBCFS_HASH_H__
 
 #include 
+#include 
+#include 
+#include 
 
 /*
  * Knuth recommends primes in approximately golden ratio to the maximum
diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h 
b/drivers/staging/lustre/lustre/fid/fid_internal.h
index 3d0003b2fb4b..14569e969a31 100644
--- a/drivers/staging/lustre/lustre/fid/fid_internal.h
+++ b/drivers/staging/lustre/lustre/fid/fid_internal.h
@@ -38,7 +38,6 @@
 #define __FID_INTERNAL_H
 
 #include 
-#include 
 
 /* Functions used internally in module. */
 
diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h 
b/drivers/staging/lustre/lustre/fld/fld_internal.h
index 9485c3d31559..e1d6aaa5c2b4 100644
--- a/drivers/staging/lustre/lustre/fld/fld_internal.h
+++ b/drivers/staging/lustre/lustre/fld/fld_internal.h
@@ -59,7 +59,6 @@
 
 #include 
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index bdb53ab77e58..7097361b3a1a 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/llite/range_lock.c 
b/drivers/staging/lustre/lustre/llite/range_lock.c
index cc9565f6bfe2..008a8874118d 100644
--- a/drivers/staging/lustre/lustre/llite/range_lock.c
+++ b/drivers/staging/lustre/lustre/llite/range_lock.c
@@ -36,6 +36,7 @@
  */
 #include "range_lock.h"
 #include 
+#include 
 
 /**
  * Initialize a range lock tree
diff --git a/drivers/staging/lustre/lustre/llite/range_lock.h 
b/drivers/staging/lustre/lustre/llite/range_lock.h
index 4af8781c71d7..9ebac09160f2 100644
--- a/drivers/staging/lustre/lustre/llite/range_lock.h
+++ b/drivers/staging/lustre/lustre/llite/range_lock.h
@@ -37,7 +37,7 @@
 #ifndef _RANGE_LOCK_H
 #define _RANGE_LOCK_H
 
-#include 
+#include 
 #include 
 
 struct range_lock {
diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c 
b/drivers/staging/lustre/lustre/llite/vvp_dev.c
index 8bda51fd97a2..31dc3c0ade01 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_dev.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c
@@ -38,6 +38,7 @@
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
+#include 
 #include 
 #include "llite_internal.h"
 #include "vvp_internal.h"
diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h 
b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
index d5849051319b..e4f762137a4a 100644
--- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
@@ -43,8 +43,6 @@
 #ifndef LOV_CL_INTERNAL_H
 #define LOV_CL_INTERNAL_H
 
-#include 
-
 #include 
 #include 
 #include "lov_internal.h"
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h 
b/drivers/staging/lustre/lustre/mgc/mgc_internal.h
index e402898cb28b..9541892b67c7 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h
+++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h
@@ -34,7 +34,6 @@
 #ifndef _MGC_INTERNAL_H
 #define _MGC_INTERNAL_H
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c 
b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 36c3f13ab9f4..32df804614d3 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -39,6 +39,7 @@
 #define D_MGC D_CONFIG /*|D_WARNING*/
 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h 
b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
index 29f318403328..2d3cba16ef34 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
@@ -43,8 +43,6 @@
 #ifndef OSC_CL_INTERNAL_H
 #define OSC_CL_INTERNAL_H
 

[PATCH 23/30] staging: lustre: remove libcfs_all.h from includes lustre/lnet

2018-05-20 Thread NeilBrown
Some of these include files didn't need to
include libcfs_all.h.  A couple did so replace with just the
base include files needed.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lnet/libcfs/tracefile.h  |8 +++-
 drivers/staging/lustre/lnet/selftest/conrpc.h   |1 -
 drivers/staging/lustre/lnet/selftest/console.h  |1 -
 drivers/staging/lustre/lnet/selftest/selftest.h |1 -
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h 
b/drivers/staging/lustre/lnet/libcfs/tracefile.h
index bbad0746f221..0608240d897f 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.h
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h
@@ -34,7 +34,13 @@
 #ifndef __LIBCFS_TRACEFILE_H__
 #define __LIBCFS_TRACEFILE_H__
 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 enum cfs_trace_buf_type {
CFS_TCD_TYPE_PROC = 0,
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.h 
b/drivers/staging/lustre/lnet/selftest/conrpc.h
index 29e743716bd6..ce2f92d04838 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.h
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.h
@@ -40,7 +40,6 @@
 #ifndef __LST_CONRPC_H__
 #define __LST_CONRPC_H__
 
-#include 
 #include 
 #include 
 #include "rpc.h"
diff --git a/drivers/staging/lustre/lnet/selftest/console.h 
b/drivers/staging/lustre/lnet/selftest/console.h
index 59e5ff9f6979..2826205e36a1 100644
--- a/drivers/staging/lustre/lnet/selftest/console.h
+++ b/drivers/staging/lustre/lnet/selftest/console.h
@@ -40,7 +40,6 @@
 #ifndef __LST_CONSOLE_H__
 #define __LST_CONSOLE_H__
 
-#include 
 #include 
 #include 
 #include "selftest.h"
diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h 
b/drivers/staging/lustre/lnet/selftest/selftest.h
index adf18515cb73..8737fa96b192 100644
--- a/drivers/staging/lustre/lnet/selftest/selftest.h
+++ b/drivers/staging/lustre/lnet/selftest/selftest.h
@@ -39,7 +39,6 @@
 
 #define LNET_ONLY
 
-#include 
 #include 
 #include 
 #include 




[PATCH 29/30] staging: lustre: move all libcfs_all includes except in lustre/lnet/libcfs/

2018-05-20 Thread NeilBrown
Again, most of these are not needed.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_string.h|2 ++
 drivers/staging/lustre/lnet/lnet/lib-socket.c  |1 -
 drivers/staging/lustre/lnet/lnet/nidstrings.c  |5 -
 drivers/staging/lustre/lnet/lnet/router_proc.c |1 -
 drivers/staging/lustre/lnet/selftest/conctl.c  |1 -
 drivers/staging/lustre/lnet/selftest/conrpc.c  |1 -
 drivers/staging/lustre/lnet/selftest/console.c |1 -
 7 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
index 66463477074a..cd7c3ccb2dc0 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
@@ -40,6 +40,8 @@
 #ifndef __LIBCFS_STRING_H__
 #define __LIBCFS_STRING_H__
 
+#include 
+
 /* libcfs_string.c */
 /* Convert a text string to a bitmask */
 int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c 
b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index b94896efc4c6..9b61260155f2 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -41,7 +41,6 @@
 #include 
 #include 
 
-#include 
 #include 
 
 static int
diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c 
b/drivers/staging/lustre/lnet/lnet/nidstrings.c
index 4c803ea88410..0f6c3fa16c65 100644
--- a/drivers/staging/lustre/lnet/lnet/nidstrings.c
+++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c
@@ -37,7 +37,10 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 
 /* max value for numeric network address */
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c 
b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 88ad787ff4ba..ae4b7f5953a0 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -20,7 +20,6 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include 
 #include 
 
 /*
diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c 
b/drivers/staging/lustre/lnet/selftest/conctl.c
index b4d521746541..906d82d90c0c 100644
--- a/drivers/staging/lustre/lnet/selftest/conctl.c
+++ b/drivers/staging/lustre/lnet/selftest/conctl.c
@@ -37,7 +37,6 @@
  * Author: Liang Zhen 
  */
 
-#include 
 #include 
 #include 
 #include "console.h"
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c 
b/drivers/staging/lustre/lnet/selftest/conrpc.c
index aefcf0db886e..0dabade3d091 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -37,7 +37,6 @@
  * Author: Liang Zhen 
  */
 
-#include 
 #include 
 #include "timer.h"
 #include "conrpc.h"
diff --git a/drivers/staging/lustre/lnet/selftest/console.c 
b/drivers/staging/lustre/lnet/selftest/console.c
index d11f854ea1f0..3c1c1b5997e0 100644
--- a/drivers/staging/lustre/lnet/selftest/console.c
+++ b/drivers/staging/lustre/lnet/selftest/console.c
@@ -37,7 +37,6 @@
  * Author: Liang Zhen 
  */
 
-#include 
 #include 
 #include "console.h"
 #include "conrpc.h"




[PATCH 28/30] staging: lustre: remove remaining libcfs_all.h includes from lustre/lustre

2018-05-20 Thread NeilBrown
Most of these aren't needed, a few can be simplified.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/lustre/include/lustre_intent.h  |2 ++
 drivers/staging/lustre/lustre/ldlm/l_lock.c|1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c   |1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lib.c  |1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|2 +-
 drivers/staging/lustre/lustre/llite/glimpse.c  |1 -
 drivers/staging/lustre/lustre/llite/lcommon_cl.c   |1 -
 drivers/staging/lustre/lustre/llite/vvp_object.c   |2 --
 drivers/staging/lustre/lustre/lov/lov_ea.c |1 -
 drivers/staging/lustre/lustre/lov/lov_merge.c  |2 --
 drivers/staging/lustre/lustre/lov/lov_obd.c|1 -
 drivers/staging/lustre/lustre/lov/lov_offset.c |2 --
 drivers/staging/lustre/lustre/lov/lov_pool.c   |2 --
 drivers/staging/lustre/lustre/lov/lov_request.c|2 --
 .../staging/lustre/lustre/obdecho/echo_client.c|1 -
 drivers/staging/lustre/lustre/osc/osc_lock.c   |1 -
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +-
 18 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_intent.h 
b/drivers/staging/lustre/lustre/include/lustre_intent.h
index 519e94fc089d..51e5c0e03872 100644
--- a/drivers/staging/lustre/lustre/include/lustre_intent.h
+++ b/drivers/staging/lustre/lustre/include/lustre_intent.h
@@ -34,6 +34,8 @@
 #ifndef LUSTRE_INTENT_H
 #define LUSTRE_INTENT_H
 
+#include 
+
 /* intent IT_XXX are defined in lustre/include/obd.h */
 
 struct lookup_intent {
diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c 
b/drivers/staging/lustre/lustre/ldlm/l_lock.c
index fbeec219a75b..296259aa51e6 100644
--- a/drivers/staging/lustre/lustre/ldlm/l_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c
@@ -32,7 +32,6 @@
  */
 
 #define DEBUG_SUBSYSTEM S_LDLM
-#include 
 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index a6435cf8924a..4da23ade2bb3 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -47,7 +47,6 @@
  */
 
 #define DEBUG_SUBSYSTEM S_LDLM
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
index d8db751cf5a7..0aa4f234a4f4 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
@@ -40,7 +40,6 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 66702428a914..a644d133063b 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -38,7 +38,6 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index 7a1d18176032..b0a29f50c7d6 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -38,7 +38,7 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c 
b/drivers/staging/lustre/lustre/llite/glimpse.c
index eddab7d2887b..ce0d51767da3 100644
--- a/drivers/staging/lustre/lustre/llite/glimpse.c
+++ b/drivers/staging/lustre/lustre/llite/glimpse.c
@@ -37,7 +37,6 @@
  *   Author: Oleg Drokin 
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c 
b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
index de1de3b2dded..d7ea39ce0cb2 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
@@ -38,7 +38,6 @@
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c 
b/drivers/staging/lustre/lustre/llite/vvp_object.c
index 5aedbdbc75b7..b2cb51c8f7f4 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_object.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_object.c
@@ -37,8 +37,6 @@
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
-#include 
-
 #include 
 
 #include "llite_internal.h"
diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c 
b/drivers/staging/lustre/lustre/lov/lov_ea.c
index 223fb76c13aa..c80320ab0858 100644
--- a/drivers/staging/lustre/lustre/lov/lov_ea.c
+++ b/drivers/staging/lustre/lustre/lov/lov_ea.c
@@ -38,7 +38,6 @@
 #define DEBUG_SUBSYSTEM S_LOV
 
 #include 
-#include 
 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c 
b/drivers/staging/lustre/lustre/lov/lov_merge.c

[PATCH 18/30] staging: lustre: replace memory_presure funcitons by standard interfaces.

2018-05-20 Thread NeilBrown
Use memalloc_noreclaim_save() and memalloc_noreclaim_restore(),
and for testing, just directly test the flag in current->flags

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_prim.h  |   31 
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   11 ---
 drivers/staging/lustre/lnet/libcfs/tracefile.c |5 ++-
 drivers/staging/lustre/lnet/lnet/lib-move.c|2 +
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|9 --
 drivers/staging/lustre/lustre/osc/osc_cache.c  |2 +
 drivers/staging/lustre/lustre/osc/osc_request.c|7 +++--
 drivers/staging/lustre/lustre/ptlrpc/niobuf.c  |7 +++--
 8 files changed, 25 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
index d4c5965c43b1..2b0dafb6155b 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
@@ -48,35 +48,4 @@
 #define NUM_CACHEPAGES totalram_pages
 #endif
 
-static inline unsigned int memory_pressure_get(void)
-{
-   return current->flags & PF_MEMALLOC;
-}
-
-static inline void memory_pressure_set(void)
-{
-   current->flags |= PF_MEMALLOC;
-}
-
-static inline void memory_pressure_clr(void)
-{
-   current->flags &= ~PF_MEMALLOC;
-}
-
-static inline int cfs_memory_pressure_get_and_set(void)
-{
-   int old = memory_pressure_get();
-
-   if (!old)
-   memory_pressure_set();
-   return old;
-}
-
-static inline void cfs_memory_pressure_restore(int old)
-{
-   if (old)
-   memory_pressure_set();
-   else
-   memory_pressure_clr();
-}
 #endif
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 14450fd5957a..01b31a6bb588 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -22,6 +22,7 @@
  *
  */
 
+#include 
 #include "socklnd.h"
 
 struct ksock_tx *
@@ -876,7 +877,7 @@ ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx 
*tx,
 int
 ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 {
-   int mpflag = 1;
+   unsigned int mpflag = 0;
int type = lntmsg->msg_type;
struct lnet_process_id target = lntmsg->msg_target;
unsigned int payload_niov = lntmsg->msg_niov;
@@ -909,13 +910,13 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct 
lnet_msg *lntmsg)
 tx_frags.paged.kiov[payload_niov]);
 
if (lntmsg->msg_vmflush)
-   mpflag = cfs_memory_pressure_get_and_set();
+   mpflag = memalloc_noreclaim_save();
tx = ksocknal_alloc_tx(KSOCK_MSG_LNET, desc_size);
if (!tx) {
CERROR("Can't allocate tx desc type %d size %d\n",
   type, desc_size);
if (lntmsg->msg_vmflush)
-   cfs_memory_pressure_restore(mpflag);
+   memalloc_noreclaim_restore(mpflag);
return -ENOMEM;
}
 
@@ -949,8 +950,8 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct 
lnet_msg *lntmsg)
 
/* The first fragment will be set later in pro_pack */
rc = ksocknal_launch_packet(ni, tx, target);
-   if (!mpflag)
-   cfs_memory_pressure_restore(mpflag);
+   if (mpflag)
+   memalloc_noreclaim_restore(mpflag);
 
if (!rc)
return 0;
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c 
b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 514e1845740e..878fbb9745a0 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -114,7 +114,7 @@ static struct cfs_trace_page *cfs_tage_alloc(gfp_t gfp)
struct cfs_trace_page *tage;
 
/* My caller is trying to free memory */
-   if (!in_interrupt() && memory_pressure_get())
+   if (!in_interrupt() && (current->flags & PF_MEMALLOC))
return NULL;
 
/*
@@ -192,7 +192,8 @@ cfs_trace_get_tage_try(struct cfs_trace_cpu_data *tcd, 
unsigned long len)
} else {
tage = cfs_tage_alloc(GFP_ATOMIC);
if (unlikely(!tage)) {
-   if (!memory_pressure_get() || in_interrupt())
+   if (!(current->flags & PF_MEMALLOC) ||
+   in_interrupt())
pr_warn_ratelimited("cannot allocate a 
tage (%ld)\n",
tcd->tcd_cur_pages);
return NULL;
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c 
b/drivers/staging/lustre/lnet/lnet/lib-move.c
index 

[PATCH 21/30] staging: lustre: don't include libcfs.h in lnet/lib-lnet.h

2018-05-20 Thread NeilBrown
We want to be more focused in what is included where.
So we remove libcfs.h from where it isn't needed.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_debug.h |1 +
 .../lustre/include/linux/libcfs/libcfs_fail.h  |3 +++
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |6 +-
 drivers/staging/lustre/lnet/lnet/config.c  |1 +
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index 07f7d306ba9a..17534a76362a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -39,6 +39,7 @@
 #ifndef __LIBCFS_DEBUG_H__
 #define __LIBCFS_DEBUG_H__
 
+#include 
 #include 
 
 /*
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
index d6fc3164e7e7..a0c3413f4e6e 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
@@ -33,6 +33,9 @@
 #ifndef _LIBCFS_FAIL_H
 #define _LIBCFS_FAIL_H
 
+#include 
+#include 
+
 extern unsigned long cfs_fail_loc;
 extern unsigned int cfs_fail_val;
 extern int cfs_fail_err;
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h 
b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index cc0150ef84fe..973c17a1c4a1 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -36,7 +36,11 @@
 #ifndef __LNET_LIB_LNET_H__
 #define __LNET_LIB_LNET_H__
 
-#include 
+#include 
+#include 
+#include 
+#include 
+
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lnet/lnet/config.c 
b/drivers/staging/lustre/lnet/lnet/config.c
index 0aea268a4f1c..55ecc1998b7e 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -34,6 +34,7 @@
 #define DEBUG_SUBSYSTEM S_LNET
 #include 
 #include 
+#include 
 #include 
 
 struct lnet_text_buf { /* tmp struct for parsing routes */




[PATCH 19/30] staging: lustre: discard libcfs_prim.h

2018-05-20 Thread NeilBrown
This file no longer contains enough content
to justify a separate file.  So merge with
libcfs.h.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   12 -
 .../lustre/include/linux/libcfs/libcfs_prim.h  |   51 
 2 files changed, 11 insertions(+), 52 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 20dfe8872d24..1880ef2b8528 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -82,7 +82,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -107,4 +106,15 @@ int lprocfs_call_handler(void *data, int write, loff_t 
*ppos,
 int (*handler)(void *data, int write, loff_t pos,
void __user *buffer, int len));
 
+/*
+ * Memory
+ */
+#if BITS_PER_LONG == 32
+/* limit to lowmem on 32-bit systems */
+#define NUM_CACHEPAGES \
+   min(totalram_pages, 1UL << (30 - PAGE_SHIFT) * 3 / 4)
+#else
+#define NUM_CACHEPAGES totalram_pages
+#endif
+
 #endif /* __LIBCFS_LIBCFS_H__ */
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
deleted file mode 100644
index 2b0dafb6155b..
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfs_prim.h
- *
- * General primitives.
- *
- */
-
-#ifndef __LIBCFS_PRIM_H__
-#define __LIBCFS_PRIM_H__
-
-/*
- * Memory
- */
-#if BITS_PER_LONG == 32
-/* limit to lowmem on 32-bit systems */
-#define NUM_CACHEPAGES \
-   min(totalram_pages, 1UL << (30 - PAGE_SHIFT) * 3 / 4)
-#else
-#define NUM_CACHEPAGES totalram_pages
-#endif
-
-#endif




[PATCH 18/30] staging: lustre: replace memory_presure funcitons by standard interfaces.

2018-05-20 Thread NeilBrown
Use memalloc_noreclaim_save() and memalloc_noreclaim_restore(),
and for testing, just directly test the flag in current->flags

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_prim.h  |   31 
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   11 ---
 drivers/staging/lustre/lnet/libcfs/tracefile.c |5 ++-
 drivers/staging/lustre/lnet/lnet/lib-move.c|2 +
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|9 --
 drivers/staging/lustre/lustre/osc/osc_cache.c  |2 +
 drivers/staging/lustre/lustre/osc/osc_request.c|7 +++--
 drivers/staging/lustre/lustre/ptlrpc/niobuf.c  |7 +++--
 8 files changed, 25 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
index d4c5965c43b1..2b0dafb6155b 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
@@ -48,35 +48,4 @@
 #define NUM_CACHEPAGES totalram_pages
 #endif
 
-static inline unsigned int memory_pressure_get(void)
-{
-   return current->flags & PF_MEMALLOC;
-}
-
-static inline void memory_pressure_set(void)
-{
-   current->flags |= PF_MEMALLOC;
-}
-
-static inline void memory_pressure_clr(void)
-{
-   current->flags &= ~PF_MEMALLOC;
-}
-
-static inline int cfs_memory_pressure_get_and_set(void)
-{
-   int old = memory_pressure_get();
-
-   if (!old)
-   memory_pressure_set();
-   return old;
-}
-
-static inline void cfs_memory_pressure_restore(int old)
-{
-   if (old)
-   memory_pressure_set();
-   else
-   memory_pressure_clr();
-}
 #endif
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 14450fd5957a..01b31a6bb588 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -22,6 +22,7 @@
  *
  */
 
+#include 
 #include "socklnd.h"
 
 struct ksock_tx *
@@ -876,7 +877,7 @@ ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx 
*tx,
 int
 ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 {
-   int mpflag = 1;
+   unsigned int mpflag = 0;
int type = lntmsg->msg_type;
struct lnet_process_id target = lntmsg->msg_target;
unsigned int payload_niov = lntmsg->msg_niov;
@@ -909,13 +910,13 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct 
lnet_msg *lntmsg)
 tx_frags.paged.kiov[payload_niov]);
 
if (lntmsg->msg_vmflush)
-   mpflag = cfs_memory_pressure_get_and_set();
+   mpflag = memalloc_noreclaim_save();
tx = ksocknal_alloc_tx(KSOCK_MSG_LNET, desc_size);
if (!tx) {
CERROR("Can't allocate tx desc type %d size %d\n",
   type, desc_size);
if (lntmsg->msg_vmflush)
-   cfs_memory_pressure_restore(mpflag);
+   memalloc_noreclaim_restore(mpflag);
return -ENOMEM;
}
 
@@ -949,8 +950,8 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct 
lnet_msg *lntmsg)
 
/* The first fragment will be set later in pro_pack */
rc = ksocknal_launch_packet(ni, tx, target);
-   if (!mpflag)
-   cfs_memory_pressure_restore(mpflag);
+   if (mpflag)
+   memalloc_noreclaim_restore(mpflag);
 
if (!rc)
return 0;
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c 
b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 514e1845740e..878fbb9745a0 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -114,7 +114,7 @@ static struct cfs_trace_page *cfs_tage_alloc(gfp_t gfp)
struct cfs_trace_page *tage;
 
/* My caller is trying to free memory */
-   if (!in_interrupt() && memory_pressure_get())
+   if (!in_interrupt() && (current->flags & PF_MEMALLOC))
return NULL;
 
/*
@@ -192,7 +192,8 @@ cfs_trace_get_tage_try(struct cfs_trace_cpu_data *tcd, 
unsigned long len)
} else {
tage = cfs_tage_alloc(GFP_ATOMIC);
if (unlikely(!tage)) {
-   if (!memory_pressure_get() || in_interrupt())
+   if (!(current->flags & PF_MEMALLOC) ||
+   in_interrupt())
pr_warn_ratelimited("cannot allocate a 
tage (%ld)\n",
tcd->tcd_cur_pages);
return NULL;
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c 
b/drivers/staging/lustre/lnet/lnet/lib-move.c
index 60464135161b..f8eaf8ff8d8d 100644

[PATCH 21/30] staging: lustre: don't include libcfs.h in lnet/lib-lnet.h

2018-05-20 Thread NeilBrown
We want to be more focused in what is included where.
So we remove libcfs.h from where it isn't needed.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_debug.h |1 +
 .../lustre/include/linux/libcfs/libcfs_fail.h  |3 +++
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |6 +-
 drivers/staging/lustre/lnet/lnet/config.c  |1 +
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index 07f7d306ba9a..17534a76362a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -39,6 +39,7 @@
 #ifndef __LIBCFS_DEBUG_H__
 #define __LIBCFS_DEBUG_H__
 
+#include 
 #include 
 
 /*
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
index d6fc3164e7e7..a0c3413f4e6e 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
@@ -33,6 +33,9 @@
 #ifndef _LIBCFS_FAIL_H
 #define _LIBCFS_FAIL_H
 
+#include 
+#include 
+
 extern unsigned long cfs_fail_loc;
 extern unsigned int cfs_fail_val;
 extern int cfs_fail_err;
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h 
b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index cc0150ef84fe..973c17a1c4a1 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -36,7 +36,11 @@
 #ifndef __LNET_LIB_LNET_H__
 #define __LNET_LIB_LNET_H__
 
-#include 
+#include 
+#include 
+#include 
+#include 
+
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/lnet/lnet/config.c 
b/drivers/staging/lustre/lnet/lnet/config.c
index 0aea268a4f1c..55ecc1998b7e 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -34,6 +34,7 @@
 #define DEBUG_SUBSYSTEM S_LNET
 #include 
 #include 
+#include 
 #include 
 
 struct lnet_text_buf { /* tmp struct for parsing routes */




[PATCH 19/30] staging: lustre: discard libcfs_prim.h

2018-05-20 Thread NeilBrown
This file no longer contains enough content
to justify a separate file.  So merge with
libcfs.h.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   12 -
 .../lustre/include/linux/libcfs/libcfs_prim.h  |   51 
 2 files changed, 11 insertions(+), 52 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 20dfe8872d24..1880ef2b8528 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -82,7 +82,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -107,4 +106,15 @@ int lprocfs_call_handler(void *data, int write, loff_t 
*ppos,
 int (*handler)(void *data, int write, loff_t pos,
void __user *buffer, int len));
 
+/*
+ * Memory
+ */
+#if BITS_PER_LONG == 32
+/* limit to lowmem on 32-bit systems */
+#define NUM_CACHEPAGES \
+   min(totalram_pages, 1UL << (30 - PAGE_SHIFT) * 3 / 4)
+#else
+#define NUM_CACHEPAGES totalram_pages
+#endif
+
 #endif /* __LIBCFS_LIBCFS_H__ */
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
deleted file mode 100644
index 2b0dafb6155b..
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfs_prim.h
- *
- * General primitives.
- *
- */
-
-#ifndef __LIBCFS_PRIM_H__
-#define __LIBCFS_PRIM_H__
-
-/*
- * Memory
- */
-#if BITS_PER_LONG == 32
-/* limit to lowmem on 32-bit systems */
-#define NUM_CACHEPAGES \
-   min(totalram_pages, 1UL << (30 - PAGE_SHIFT) * 3 / 4)
-#else
-#define NUM_CACHEPAGES totalram_pages
-#endif
-
-#endif




[PATCH 16/30] staging: lustre: move lnet_debug_log_upcall declaration to tracefile.h

2018-05-20 Thread NeilBrown
Both files that use this variable include tracefile.h, and it
seems a more suitable home for the declaration.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |5 -
 drivers/staging/lustre/lnet/libcfs/tracefile.h |5 +
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 947fba9445dc..c7d025cccb40 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -103,11 +103,6 @@ static inline int notifier_from_ioctl_errno(int err)
 
 int libcfs_setup(void);
 
-/**
- * The path of debug log dump upcall script.
- */
-extern char lnet_debug_log_upcall[1024];
-
 extern struct workqueue_struct *cfs_rehash_wq;
 
 void lustre_insert_debugfs(struct ctl_table *table);
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h 
b/drivers/staging/lustre/lnet/libcfs/tracefile.h
index a29d6eb3a785..b1c7a98ea192 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.h
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h
@@ -49,6 +49,11 @@ enum cfs_trace_buf_type {
 extern char cfs_tracefile[TRACEFILE_NAME_SIZE];
 extern long long cfs_tracefile_size;
 
+/**
+ * The path of debug log dump upcall script.
+ */
+extern char lnet_debug_log_upcall[1024];
+
 void libcfs_run_debug_log_upcall(char *file);
 
 int  cfs_tracefile_init_arch(void);




[PATCH 22/30] staging: lustre: remove libcfs_all.h includes from lnet/klnd

2018-05-20 Thread NeilBrown
Other smaller include files are sufficient.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h|1 -
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h|1 -
 .../lustre/lnet/klnds/socklnd/socklnd_lib.c|1 +
 3 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index 7c0e9f66b16a..217503f125bc 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -64,7 +64,6 @@
 
 #define DEBUG_SUBSYSTEM S_LND
 
-#include 
 #include 
 
 #define IBLND_PEER_HASH_SIZE   101 /* # peer lists */
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index e080aac508ff..4e5c89a692a3 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -47,7 +47,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
index 7941cfa526bc..93a02cd6b6b5 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
@@ -31,6 +31,7 @@
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
+#include 
 #include "socklnd.h"
 
 int




[PATCH 22/30] staging: lustre: remove libcfs_all.h includes from lnet/klnd

2018-05-20 Thread NeilBrown
Other smaller include files are sufficient.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h|1 -
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h|1 -
 .../lustre/lnet/klnds/socklnd/socklnd_lib.c|1 +
 3 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index 7c0e9f66b16a..217503f125bc 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -64,7 +64,6 @@
 
 #define DEBUG_SUBSYSTEM S_LND
 
-#include 
 #include 
 
 #define IBLND_PEER_HASH_SIZE   101 /* # peer lists */
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index e080aac508ff..4e5c89a692a3 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -47,7 +47,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
index 7941cfa526bc..93a02cd6b6b5 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
@@ -31,6 +31,7 @@
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
+#include 
 #include "socklnd.h"
 
 int




[PATCH 16/30] staging: lustre: move lnet_debug_log_upcall declaration to tracefile.h

2018-05-20 Thread NeilBrown
Both files that use this variable include tracefile.h, and it
seems a more suitable home for the declaration.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |5 -
 drivers/staging/lustre/lnet/libcfs/tracefile.h |5 +
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 947fba9445dc..c7d025cccb40 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -103,11 +103,6 @@ static inline int notifier_from_ioctl_errno(int err)
 
 int libcfs_setup(void);
 
-/**
- * The path of debug log dump upcall script.
- */
-extern char lnet_debug_log_upcall[1024];
-
 extern struct workqueue_struct *cfs_rehash_wq;
 
 void lustre_insert_debugfs(struct ctl_table *table);
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h 
b/drivers/staging/lustre/lnet/libcfs/tracefile.h
index a29d6eb3a785..b1c7a98ea192 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.h
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h
@@ -49,6 +49,11 @@ enum cfs_trace_buf_type {
 extern char cfs_tracefile[TRACEFILE_NAME_SIZE];
 extern long long cfs_tracefile_size;
 
+/**
+ * The path of debug log dump upcall script.
+ */
+extern char lnet_debug_log_upcall[1024];
+
 void libcfs_run_debug_log_upcall(char *file);
 
 int  cfs_tracefile_init_arch(void);




[PATCH 17/30] staging: lustre: move RESV_PORT definitions to lnet/lib-lnet.h

2018-05-20 Thread NeilBrown
These are network related on only used in lnet, so move
to lib-lnet.h

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |4 
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |4 
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index c7d025cccb40..20dfe8872d24 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -89,10 +89,6 @@
 
 #define LIBCFS_VERSION "0.7.0"
 
-/* need both kernel and user-land acceptor */
-#define LNET_ACCEPTOR_MIN_RESERVED_PORT512
-#define LNET_ACCEPTOR_MAX_RESERVED_PORT1023
-
 extern struct blocking_notifier_head libcfs_ioctl_list;
 static inline int notifier_from_ioctl_errno(int err)
 {
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h 
b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index df4c72507a15..82561e9e44eb 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -68,6 +68,10 @@ extern struct lnet the_lnet; /* THE network */
 /** exclusive lock */
 #define LNET_LOCK_EX   CFS_PERCPT_LOCK_EX
 
+/* need both kernel and user-land acceptor */
+#define LNET_ACCEPTOR_MIN_RESERVED_PORT512
+#define LNET_ACCEPTOR_MAX_RESERVED_PORT1023
+
 static inline int lnet_is_route_alive(struct lnet_route *route)
 {
/* gateway is down */




[PATCH 15/30] staging: lustre: make lnet_debugfs_symlink_def local to libcfs/modules.c

2018-05-20 Thread NeilBrown
This type is only used in libcfs/module.c, so make it local to there.
If any other module ever wanted to add its own symlinks,
it would probably be easiest to export lnet_debugfs_root
and just call debugfs_create_symlink as required.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |8 +--
 drivers/staging/lustre/lnet/libcfs/module.c|   23 +++-
 drivers/staging/lustre/lnet/lnet/router_proc.c |2 +-
 3 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index ab77cf83af0f..947fba9445dc 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -110,13 +110,7 @@ extern char lnet_debug_log_upcall[1024];
 
 extern struct workqueue_struct *cfs_rehash_wq;
 
-struct lnet_debugfs_symlink_def {
-   char *name;
-   char *target;
-};
-
-void lustre_insert_debugfs(struct ctl_table *table,
-  const struct lnet_debugfs_symlink_def *symlinks);
+void lustre_insert_debugfs(struct ctl_table *table);
 int lprocfs_call_handler(void *data, int write, loff_t *ppos,
 void __user *buffer, size_t *lenp,
 int (*handler)(void *data, int write, loff_t pos,
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c 
b/drivers/staging/lustre/lnet/libcfs/module.c
index b3a7c1a912ba..3e535d82df27 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -60,6 +60,11 @@
 #include 
 #include "tracefile.h"
 
+struct lnet_debugfs_symlink_def {
+   char *name;
+   char *target;
+};
+
 static struct dentry *lnet_debugfs_root;
 
 BLOCKING_NOTIFIER_HEAD(libcfs_ioctl_list);
@@ -620,8 +625,7 @@ static const struct file_operations 
*lnet_debugfs_fops_select(umode_t mode)
return _debugfs_file_operations_rw;
 }
 
-void lustre_insert_debugfs(struct ctl_table *table,
-  const struct lnet_debugfs_symlink_def *symlinks)
+void lustre_insert_debugfs(struct ctl_table *table)
 {
if (!lnet_debugfs_root)
lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
@@ -630,19 +634,24 @@ void lustre_insert_debugfs(struct ctl_table *table,
if (IS_ERR_OR_NULL(lnet_debugfs_root))
return;
 
-   /* We don't save the dentry returned in next two calls, because
-* we don't call debugfs_remove() but rather remove_recursive()
+   /*
+* We don't save the dentry returned because we don't call
+* debugfs_remove() but rather remove_recursive()
 */
for (; table->procname; table++)
debugfs_create_file(table->procname, table->mode,
lnet_debugfs_root, table,
lnet_debugfs_fops_select(table->mode));
+}
+EXPORT_SYMBOL_GPL(lustre_insert_debugfs);
 
+static void lustre_insert_debugfs_links(
+   const struct lnet_debugfs_symlink_def *symlinks)
+{
for (; symlinks && symlinks->name; symlinks++)
debugfs_create_symlink(symlinks->name, lnet_debugfs_root,
   symlinks->target);
 }
-EXPORT_SYMBOL_GPL(lustre_insert_debugfs);
 
 static void lustre_remove_debugfs(void)
 {
@@ -688,7 +697,9 @@ int libcfs_setup(void)
goto err;
}
 
-   lustre_insert_debugfs(lnet_table, lnet_debugfs_symlinks);
+   lustre_insert_debugfs(lnet_table);
+   if (!IS_ERR_OR_NULL(lnet_debugfs_root))
+   lustre_insert_debugfs_links(lnet_debugfs_symlinks);
 
CDEBUG(D_OTHER, "portals setup OK\n");
 out:
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c 
b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 015dccbc4a58..36ae5b016985 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -900,7 +900,7 @@ static struct ctl_table lnet_table[] = {
 
 void lnet_router_debugfs_init(void)
 {
-   lustre_insert_debugfs(lnet_table, NULL);
+   lustre_insert_debugfs(lnet_table);
 }
 
 void lnet_router_debugfs_fini(void)




[PATCH 17/30] staging: lustre: move RESV_PORT definitions to lnet/lib-lnet.h

2018-05-20 Thread NeilBrown
These are network related on only used in lnet, so move
to lib-lnet.h

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |4 
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |4 
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index c7d025cccb40..20dfe8872d24 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -89,10 +89,6 @@
 
 #define LIBCFS_VERSION "0.7.0"
 
-/* need both kernel and user-land acceptor */
-#define LNET_ACCEPTOR_MIN_RESERVED_PORT512
-#define LNET_ACCEPTOR_MAX_RESERVED_PORT1023
-
 extern struct blocking_notifier_head libcfs_ioctl_list;
 static inline int notifier_from_ioctl_errno(int err)
 {
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h 
b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index df4c72507a15..82561e9e44eb 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -68,6 +68,10 @@ extern struct lnet the_lnet; /* THE network */
 /** exclusive lock */
 #define LNET_LOCK_EX   CFS_PERCPT_LOCK_EX
 
+/* need both kernel and user-land acceptor */
+#define LNET_ACCEPTOR_MIN_RESERVED_PORT512
+#define LNET_ACCEPTOR_MAX_RESERVED_PORT1023
+
 static inline int lnet_is_route_alive(struct lnet_route *route)
 {
/* gateway is down */




[PATCH 15/30] staging: lustre: make lnet_debugfs_symlink_def local to libcfs/modules.c

2018-05-20 Thread NeilBrown
This type is only used in libcfs/module.c, so make it local to there.
If any other module ever wanted to add its own symlinks,
it would probably be easiest to export lnet_debugfs_root
and just call debugfs_create_symlink as required.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |8 +--
 drivers/staging/lustre/lnet/libcfs/module.c|   23 +++-
 drivers/staging/lustre/lnet/lnet/router_proc.c |2 +-
 3 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index ab77cf83af0f..947fba9445dc 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -110,13 +110,7 @@ extern char lnet_debug_log_upcall[1024];
 
 extern struct workqueue_struct *cfs_rehash_wq;
 
-struct lnet_debugfs_symlink_def {
-   char *name;
-   char *target;
-};
-
-void lustre_insert_debugfs(struct ctl_table *table,
-  const struct lnet_debugfs_symlink_def *symlinks);
+void lustre_insert_debugfs(struct ctl_table *table);
 int lprocfs_call_handler(void *data, int write, loff_t *ppos,
 void __user *buffer, size_t *lenp,
 int (*handler)(void *data, int write, loff_t pos,
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c 
b/drivers/staging/lustre/lnet/libcfs/module.c
index b3a7c1a912ba..3e535d82df27 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -60,6 +60,11 @@
 #include 
 #include "tracefile.h"
 
+struct lnet_debugfs_symlink_def {
+   char *name;
+   char *target;
+};
+
 static struct dentry *lnet_debugfs_root;
 
 BLOCKING_NOTIFIER_HEAD(libcfs_ioctl_list);
@@ -620,8 +625,7 @@ static const struct file_operations 
*lnet_debugfs_fops_select(umode_t mode)
return _debugfs_file_operations_rw;
 }
 
-void lustre_insert_debugfs(struct ctl_table *table,
-  const struct lnet_debugfs_symlink_def *symlinks)
+void lustre_insert_debugfs(struct ctl_table *table)
 {
if (!lnet_debugfs_root)
lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
@@ -630,19 +634,24 @@ void lustre_insert_debugfs(struct ctl_table *table,
if (IS_ERR_OR_NULL(lnet_debugfs_root))
return;
 
-   /* We don't save the dentry returned in next two calls, because
-* we don't call debugfs_remove() but rather remove_recursive()
+   /*
+* We don't save the dentry returned because we don't call
+* debugfs_remove() but rather remove_recursive()
 */
for (; table->procname; table++)
debugfs_create_file(table->procname, table->mode,
lnet_debugfs_root, table,
lnet_debugfs_fops_select(table->mode));
+}
+EXPORT_SYMBOL_GPL(lustre_insert_debugfs);
 
+static void lustre_insert_debugfs_links(
+   const struct lnet_debugfs_symlink_def *symlinks)
+{
for (; symlinks && symlinks->name; symlinks++)
debugfs_create_symlink(symlinks->name, lnet_debugfs_root,
   symlinks->target);
 }
-EXPORT_SYMBOL_GPL(lustre_insert_debugfs);
 
 static void lustre_remove_debugfs(void)
 {
@@ -688,7 +697,9 @@ int libcfs_setup(void)
goto err;
}
 
-   lustre_insert_debugfs(lnet_table, lnet_debugfs_symlinks);
+   lustre_insert_debugfs(lnet_table);
+   if (!IS_ERR_OR_NULL(lnet_debugfs_root))
+   lustre_insert_debugfs_links(lnet_debugfs_symlinks);
 
CDEBUG(D_OTHER, "portals setup OK\n");
 out:
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c 
b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 015dccbc4a58..36ae5b016985 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -900,7 +900,7 @@ static struct ctl_table lnet_table[] = {
 
 void lnet_router_debugfs_init(void)
 {
-   lustre_insert_debugfs(lnet_table, NULL);
+   lustre_insert_debugfs(lnet_table);
 }
 
 void lnet_router_debugfs_fini(void)




[PATCH 20/30] staging: lustre: start moving includes out of libcfs.h

2018-05-20 Thread NeilBrown
Lots of places include libcfs.h, and it includes lots of other include
files.  Many of these aren't needed in many places.  It is tidier and
better documentation to just include what is needed.

So remove all the includes from libcfs.h and create libcfs_all.h which
contains them.  Then change every reference to libcfs.h to instead
include libcfs_all.h

Next several patches will remove that from various files
in small batches

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   48 ---
 .../lustre/include/linux/libcfs/libcfs_all.h   |   88 
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |2 
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h|2 
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h|2 
 drivers/staging/lustre/lnet/libcfs/debug.c |2 
 drivers/staging/lustre/lnet/libcfs/fail.c  |2 
 drivers/staging/lustre/lnet/libcfs/hash.c  |2 
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c|4 -
 drivers/staging/lustre/lnet/libcfs/libcfs_lock.c   |2 
 drivers/staging/lustre/lnet/libcfs/libcfs_mem.c|2 
 drivers/staging/lustre/lnet/libcfs/libcfs_string.c |2 
 drivers/staging/lustre/lnet/libcfs/linux-crypto.c  |2 
 drivers/staging/lustre/lnet/libcfs/linux-debug.c   |2 
 .../staging/lustre/lnet/libcfs/linux-tracefile.c   |2 
 drivers/staging/lustre/lnet/libcfs/module.c|2 
 drivers/staging/lustre/lnet/libcfs/tracefile.c |2 
 drivers/staging/lustre/lnet/libcfs/tracefile.h |2 
 drivers/staging/lustre/lnet/lnet/lib-socket.c  |2 
 drivers/staging/lustre/lnet/lnet/nidstrings.c  |2 
 drivers/staging/lustre/lnet/lnet/router_proc.c |2 
 drivers/staging/lustre/lnet/selftest/conctl.c  |2 
 drivers/staging/lustre/lnet/selftest/conrpc.c  |2 
 drivers/staging/lustre/lnet/selftest/conrpc.h  |2 
 drivers/staging/lustre/lnet/selftest/console.c |2 
 drivers/staging/lustre/lnet/selftest/console.h |2 
 drivers/staging/lustre/lnet/selftest/selftest.h|2 
 drivers/staging/lustre/lustre/fid/fid_internal.h   |2 
 drivers/staging/lustre/lustre/fid/fid_lib.c|2 
 drivers/staging/lustre/lustre/fid/fid_request.c|2 
 drivers/staging/lustre/lustre/fid/lproc_fid.c  |2 
 drivers/staging/lustre/lustre/fld/fld_cache.c  |2 
 drivers/staging/lustre/lustre/fld/fld_internal.h   |2 
 drivers/staging/lustre/lustre/fld/fld_request.c|2 
 drivers/staging/lustre/lustre/fld/lproc_fld.c  |2 
 .../staging/lustre/lustre/include/lprocfs_status.h |2 
 drivers/staging/lustre/lustre/include/lu_object.h  |2 
 .../staging/lustre/lustre/include/lustre_disk.h|2 
 drivers/staging/lustre/lustre/include/lustre_fid.h |2 
 drivers/staging/lustre/lustre/include/lustre_fld.h |2 
 .../staging/lustre/lustre/include/lustre_handles.h |2 
 drivers/staging/lustre/lustre/include/lustre_lib.h |2 
 drivers/staging/lustre/lustre/include/lustre_mdc.h |2 
 drivers/staging/lustre/lustre/include/lustre_mds.h |2 
 drivers/staging/lustre/lustre/include/lustre_net.h |2 
 drivers/staging/lustre/lustre/include/obd_cksum.h  |2 
 .../staging/lustre/lustre/include/obd_support.h|2 
 drivers/staging/lustre/lustre/ldlm/l_lock.c|2 
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c   |2 
 drivers/staging/lustre/lustre/ldlm/ldlm_lib.c  |2 
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |2 
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|2 
 drivers/staging/lustre/lustre/llite/glimpse.c  |2 
 drivers/staging/lustre/lustre/llite/lcommon_cl.c   |2 
 drivers/staging/lustre/lustre/llite/range_lock.h   |2 
 drivers/staging/lustre/lustre/llite/vvp_object.c   |2 
 .../staging/lustre/lustre/lov/lov_cl_internal.h|2 
 drivers/staging/lustre/lustre/lov/lov_ea.c |2 
 drivers/staging/lustre/lustre/lov/lov_merge.c  |2 
 drivers/staging/lustre/lustre/lov/lov_obd.c|2 
 drivers/staging/lustre/lustre/lov/lov_offset.c |2 
 drivers/staging/lustre/lustre/lov/lov_pool.c   |2 
 drivers/staging/lustre/lustre/lov/lov_request.c|2 
 drivers/staging/lustre/lustre/mgc/mgc_internal.h   |2 
 drivers/staging/lustre/lustre/obdclass/cl_object.c |2 
 drivers/staging/lustre/lustre/obdclass/cl_page.c   |2 
 .../lustre/lustre/obdclass/linux/linux-module.c|2 
 drivers/staging/lustre/lustre/obdclass/lu_object.c |2 
 drivers/staging/lustre/lustre/obdclass/lu_ref.c|2 
 drivers/staging/lustre/lustre/obdclass/uuid.c  |2 
 .../staging/lustre/lustre/obdecho/echo_client.c|2 
 .../staging/lustre/lustre/osc/osc_cl_internal.h|2 
 drivers/staging/lustre/lustre/osc/osc_lock.c   |2 
 drivers/staging/lustre/lustre/osc/osc_request.c|2 
 drivers/staging/lustre/lustre/ptlrpc/errno.c  

[PATCH 20/30] staging: lustre: start moving includes out of libcfs.h

2018-05-20 Thread NeilBrown
Lots of places include libcfs.h, and it includes lots of other include
files.  Many of these aren't needed in many places.  It is tidier and
better documentation to just include what is needed.

So remove all the includes from libcfs.h and create libcfs_all.h which
contains them.  Then change every reference to libcfs.h to instead
include libcfs_all.h

Next several patches will remove that from various files
in small batches

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   48 ---
 .../lustre/include/linux/libcfs/libcfs_all.h   |   88 
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |2 
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h|2 
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h|2 
 drivers/staging/lustre/lnet/libcfs/debug.c |2 
 drivers/staging/lustre/lnet/libcfs/fail.c  |2 
 drivers/staging/lustre/lnet/libcfs/hash.c  |2 
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c|4 -
 drivers/staging/lustre/lnet/libcfs/libcfs_lock.c   |2 
 drivers/staging/lustre/lnet/libcfs/libcfs_mem.c|2 
 drivers/staging/lustre/lnet/libcfs/libcfs_string.c |2 
 drivers/staging/lustre/lnet/libcfs/linux-crypto.c  |2 
 drivers/staging/lustre/lnet/libcfs/linux-debug.c   |2 
 .../staging/lustre/lnet/libcfs/linux-tracefile.c   |2 
 drivers/staging/lustre/lnet/libcfs/module.c|2 
 drivers/staging/lustre/lnet/libcfs/tracefile.c |2 
 drivers/staging/lustre/lnet/libcfs/tracefile.h |2 
 drivers/staging/lustre/lnet/lnet/lib-socket.c  |2 
 drivers/staging/lustre/lnet/lnet/nidstrings.c  |2 
 drivers/staging/lustre/lnet/lnet/router_proc.c |2 
 drivers/staging/lustre/lnet/selftest/conctl.c  |2 
 drivers/staging/lustre/lnet/selftest/conrpc.c  |2 
 drivers/staging/lustre/lnet/selftest/conrpc.h  |2 
 drivers/staging/lustre/lnet/selftest/console.c |2 
 drivers/staging/lustre/lnet/selftest/console.h |2 
 drivers/staging/lustre/lnet/selftest/selftest.h|2 
 drivers/staging/lustre/lustre/fid/fid_internal.h   |2 
 drivers/staging/lustre/lustre/fid/fid_lib.c|2 
 drivers/staging/lustre/lustre/fid/fid_request.c|2 
 drivers/staging/lustre/lustre/fid/lproc_fid.c  |2 
 drivers/staging/lustre/lustre/fld/fld_cache.c  |2 
 drivers/staging/lustre/lustre/fld/fld_internal.h   |2 
 drivers/staging/lustre/lustre/fld/fld_request.c|2 
 drivers/staging/lustre/lustre/fld/lproc_fld.c  |2 
 .../staging/lustre/lustre/include/lprocfs_status.h |2 
 drivers/staging/lustre/lustre/include/lu_object.h  |2 
 .../staging/lustre/lustre/include/lustre_disk.h|2 
 drivers/staging/lustre/lustre/include/lustre_fid.h |2 
 drivers/staging/lustre/lustre/include/lustre_fld.h |2 
 .../staging/lustre/lustre/include/lustre_handles.h |2 
 drivers/staging/lustre/lustre/include/lustre_lib.h |2 
 drivers/staging/lustre/lustre/include/lustre_mdc.h |2 
 drivers/staging/lustre/lustre/include/lustre_mds.h |2 
 drivers/staging/lustre/lustre/include/lustre_net.h |2 
 drivers/staging/lustre/lustre/include/obd_cksum.h  |2 
 .../staging/lustre/lustre/include/obd_support.h|2 
 drivers/staging/lustre/lustre/ldlm/l_lock.c|2 
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c   |2 
 drivers/staging/lustre/lustre/ldlm/ldlm_lib.c  |2 
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |2 
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|2 
 drivers/staging/lustre/lustre/llite/glimpse.c  |2 
 drivers/staging/lustre/lustre/llite/lcommon_cl.c   |2 
 drivers/staging/lustre/lustre/llite/range_lock.h   |2 
 drivers/staging/lustre/lustre/llite/vvp_object.c   |2 
 .../staging/lustre/lustre/lov/lov_cl_internal.h|2 
 drivers/staging/lustre/lustre/lov/lov_ea.c |2 
 drivers/staging/lustre/lustre/lov/lov_merge.c  |2 
 drivers/staging/lustre/lustre/lov/lov_obd.c|2 
 drivers/staging/lustre/lustre/lov/lov_offset.c |2 
 drivers/staging/lustre/lustre/lov/lov_pool.c   |2 
 drivers/staging/lustre/lustre/lov/lov_request.c|2 
 drivers/staging/lustre/lustre/mgc/mgc_internal.h   |2 
 drivers/staging/lustre/lustre/obdclass/cl_object.c |2 
 drivers/staging/lustre/lustre/obdclass/cl_page.c   |2 
 .../lustre/lustre/obdclass/linux/linux-module.c|2 
 drivers/staging/lustre/lustre/obdclass/lu_object.c |2 
 drivers/staging/lustre/lustre/obdclass/lu_ref.c|2 
 drivers/staging/lustre/lustre/obdclass/uuid.c  |2 
 .../staging/lustre/lustre/obdecho/echo_client.c|2 
 .../staging/lustre/lustre/osc/osc_cl_internal.h|2 
 drivers/staging/lustre/lustre/osc/osc_lock.c   |2 
 drivers/staging/lustre/lustre/osc/osc_request.c|2 
 drivers/staging/lustre/lustre/ptlrpc/errno.c   |2 
 

[PATCH 13/30] staging: lustre: replace libcfs_register_ioctl with a blocking notifier_chain

2018-05-20 Thread NeilBrown
libcfs allows other modules to register handlers for ioctls.
The implementation it uses for this is nearly identical to a
blocking notifier chain, so change to use that.

The biggest difference is that the return value from notifier has a
defined format, where libcfs_register_ioctl uses -EINVAL to mean
"continue".  This requires a little bit of conversion.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   19 ++
 drivers/staging/lustre/lnet/libcfs/module.c|   64 
 drivers/staging/lustre/lnet/lnet/module.c  |   38 
 drivers/staging/lustre/lnet/selftest/conctl.c  |   27 +---
 drivers/staging/lustre/lnet/selftest/console.c |   10 ++-
 drivers/staging/lustre/lnet/selftest/console.h |3 +
 6 files changed, 70 insertions(+), 91 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index d9002e7424d4..63ea0e99ec58 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -93,19 +93,14 @@
 #define LNET_ACCEPTOR_MIN_RESERVED_PORT512
 #define LNET_ACCEPTOR_MAX_RESERVED_PORT1023
 
-struct libcfs_ioctl_handler {
-   struct list_head item;
-   int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
-};
-
-#define DECLARE_IOCTL_HANDLER(ident, func) \
-   struct libcfs_ioctl_handler ident = {   \
-   .item   = LIST_HEAD_INIT(ident.item),   \
-   .handle_ioctl   = func  \
-   }
+extern struct blocking_notifier_head libcfs_ioctl_list;
+static inline int notifier_from_ioctl_errno(int err)
+{
+   if (err == -EINVAL)
+   return NOTIFY_OK;
+   return notifier_from_errno(err) | NOTIFY_STOP_MASK;
+}
 
-int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
-int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
 int libcfs_setup(void);
 
 #define _LIBCFS_H
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c 
b/drivers/staging/lustre/lnet/libcfs/module.c
index 3e51aae751c5..b3a7c1a912ba 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -62,38 +62,8 @@
 
 static struct dentry *lnet_debugfs_root;
 
-static DECLARE_RWSEM(ioctl_list_sem);
-static LIST_HEAD(ioctl_list);
-
-int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand)
-{
-   int rc = 0;
-
-   down_write(_list_sem);
-   if (!list_empty(>item))
-   rc = -EBUSY;
-   else
-   list_add_tail(>item, _list);
-   up_write(_list_sem);
-
-   return rc;
-}
-EXPORT_SYMBOL(libcfs_register_ioctl);
-
-int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand)
-{
-   int rc = 0;
-
-   down_write(_list_sem);
-   if (list_empty(>item))
-   rc = -ENOENT;
-   else
-   list_del_init(>item);
-   up_write(_list_sem);
-
-   return rc;
-}
-EXPORT_SYMBOL(libcfs_deregister_ioctl);
+BLOCKING_NOTIFIER_HEAD(libcfs_ioctl_list);
+EXPORT_SYMBOL(libcfs_ioctl_list);
 
 static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
 {
@@ -268,24 +238,18 @@ static int libcfs_ioctl(unsigned long cmd, void __user 
*uparam)
libcfs_debug_mark_buffer(data->ioc_inlbuf1);
break;
 
-   default: {
-   struct libcfs_ioctl_handler *hand;
-
-   err = -EINVAL;
-   down_read(_list_sem);
-   list_for_each_entry(hand, _list, item) {
-   err = hand->handle_ioctl(cmd, hdr);
-   if (err == -EINVAL)
-   continue;
-
-   if (!err) {
-   if (copy_to_user(uparam, hdr, hdr->ioc_len))
-   err = -EFAULT;
-   }
-   break;
-   }
-   up_read(_list_sem);
-   break; }
+   default:
+   err = blocking_notifier_call_chain(_ioctl_list,
+  cmd, hdr);
+   if (!(err & NOTIFY_STOP_MASK))
+   /* No-one claimed the ioctl */
+   err = -EINVAL;
+   else
+   err = notifier_to_errno(err);
+   if (!err)
+   if (copy_to_user(uparam, hdr, hdr->ioc_len))
+   err = -EFAULT;
+   break;
}
 out:
kvfree(hdr);
diff --git a/drivers/staging/lustre/lnet/lnet/module.c 
b/drivers/staging/lustre/lnet/lnet/module.c
index f6e912e79ca7..9d06664f0c17 100644
--- a/drivers/staging/lustre/lnet/lnet/module.c
+++ b/drivers/staging/lustre/lnet/lnet/module.c
@@ -136,30 +136,37 @@ lnet_dyn_unconfigure(struct libcfs_ioctl_hdr *hdr)
 }
 
 

[PATCH 14/30] staging: lustre: clean up __LIBCFS_H macro

2018-05-20 Thread NeilBrown
There is some confusion with names here - make it all uniform.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 63ea0e99ec58..ab77cf83af0f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -103,8 +103,6 @@ static inline int notifier_from_ioctl_errno(int err)
 
 int libcfs_setup(void);
 
-#define _LIBCFS_H
-
 /**
  * The path of debug log dump upcall script.
  */
@@ -124,4 +122,4 @@ int lprocfs_call_handler(void *data, int write, loff_t 
*ppos,
 int (*handler)(void *data, int write, loff_t pos,
void __user *buffer, int len));
 
-#endif /* _LIBCFS_H */
+#endif /* __LIBCFS_LIBCFS_H__ */




[PATCH 14/30] staging: lustre: clean up __LIBCFS_H macro

2018-05-20 Thread NeilBrown
There is some confusion with names here - make it all uniform.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 63ea0e99ec58..ab77cf83af0f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -103,8 +103,6 @@ static inline int notifier_from_ioctl_errno(int err)
 
 int libcfs_setup(void);
 
-#define _LIBCFS_H
-
 /**
  * The path of debug log dump upcall script.
  */
@@ -124,4 +122,4 @@ int lprocfs_call_handler(void *data, int write, loff_t 
*ppos,
 int (*handler)(void *data, int write, loff_t pos,
void __user *buffer, int len));
 
-#endif /* _LIBCFS_H */
+#endif /* __LIBCFS_LIBCFS_H__ */




[PATCH 13/30] staging: lustre: replace libcfs_register_ioctl with a blocking notifier_chain

2018-05-20 Thread NeilBrown
libcfs allows other modules to register handlers for ioctls.
The implementation it uses for this is nearly identical to a
blocking notifier chain, so change to use that.

The biggest difference is that the return value from notifier has a
defined format, where libcfs_register_ioctl uses -EINVAL to mean
"continue".  This requires a little bit of conversion.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   19 ++
 drivers/staging/lustre/lnet/libcfs/module.c|   64 
 drivers/staging/lustre/lnet/lnet/module.c  |   38 
 drivers/staging/lustre/lnet/selftest/conctl.c  |   27 +---
 drivers/staging/lustre/lnet/selftest/console.c |   10 ++-
 drivers/staging/lustre/lnet/selftest/console.h |3 +
 6 files changed, 70 insertions(+), 91 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index d9002e7424d4..63ea0e99ec58 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -93,19 +93,14 @@
 #define LNET_ACCEPTOR_MIN_RESERVED_PORT512
 #define LNET_ACCEPTOR_MAX_RESERVED_PORT1023
 
-struct libcfs_ioctl_handler {
-   struct list_head item;
-   int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
-};
-
-#define DECLARE_IOCTL_HANDLER(ident, func) \
-   struct libcfs_ioctl_handler ident = {   \
-   .item   = LIST_HEAD_INIT(ident.item),   \
-   .handle_ioctl   = func  \
-   }
+extern struct blocking_notifier_head libcfs_ioctl_list;
+static inline int notifier_from_ioctl_errno(int err)
+{
+   if (err == -EINVAL)
+   return NOTIFY_OK;
+   return notifier_from_errno(err) | NOTIFY_STOP_MASK;
+}
 
-int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
-int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
 int libcfs_setup(void);
 
 #define _LIBCFS_H
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c 
b/drivers/staging/lustre/lnet/libcfs/module.c
index 3e51aae751c5..b3a7c1a912ba 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -62,38 +62,8 @@
 
 static struct dentry *lnet_debugfs_root;
 
-static DECLARE_RWSEM(ioctl_list_sem);
-static LIST_HEAD(ioctl_list);
-
-int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand)
-{
-   int rc = 0;
-
-   down_write(_list_sem);
-   if (!list_empty(>item))
-   rc = -EBUSY;
-   else
-   list_add_tail(>item, _list);
-   up_write(_list_sem);
-
-   return rc;
-}
-EXPORT_SYMBOL(libcfs_register_ioctl);
-
-int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand)
-{
-   int rc = 0;
-
-   down_write(_list_sem);
-   if (list_empty(>item))
-   rc = -ENOENT;
-   else
-   list_del_init(>item);
-   up_write(_list_sem);
-
-   return rc;
-}
-EXPORT_SYMBOL(libcfs_deregister_ioctl);
+BLOCKING_NOTIFIER_HEAD(libcfs_ioctl_list);
+EXPORT_SYMBOL(libcfs_ioctl_list);
 
 static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
 {
@@ -268,24 +238,18 @@ static int libcfs_ioctl(unsigned long cmd, void __user 
*uparam)
libcfs_debug_mark_buffer(data->ioc_inlbuf1);
break;
 
-   default: {
-   struct libcfs_ioctl_handler *hand;
-
-   err = -EINVAL;
-   down_read(_list_sem);
-   list_for_each_entry(hand, _list, item) {
-   err = hand->handle_ioctl(cmd, hdr);
-   if (err == -EINVAL)
-   continue;
-
-   if (!err) {
-   if (copy_to_user(uparam, hdr, hdr->ioc_len))
-   err = -EFAULT;
-   }
-   break;
-   }
-   up_read(_list_sem);
-   break; }
+   default:
+   err = blocking_notifier_call_chain(_ioctl_list,
+  cmd, hdr);
+   if (!(err & NOTIFY_STOP_MASK))
+   /* No-one claimed the ioctl */
+   err = -EINVAL;
+   else
+   err = notifier_to_errno(err);
+   if (!err)
+   if (copy_to_user(uparam, hdr, hdr->ioc_len))
+   err = -EFAULT;
+   break;
}
 out:
kvfree(hdr);
diff --git a/drivers/staging/lustre/lnet/lnet/module.c 
b/drivers/staging/lustre/lnet/lnet/module.c
index f6e912e79ca7..9d06664f0c17 100644
--- a/drivers/staging/lustre/lnet/lnet/module.c
+++ b/drivers/staging/lustre/lnet/lnet/module.c
@@ -136,30 +136,37 @@ lnet_dyn_unconfigure(struct libcfs_ioctl_hdr *hdr)
 }
 
 static int

[PATCH 12/30] staging: lustre: discard cfs_block_sigsinv()

2018-05-20 Thread NeilBrown
cfs_block_sigsinv() and cfs_restore_sigs() are simple
wrappers which save a couple of line of code and
hurt readability for people not familiar with them.
They aren't used often enough to be worthwhile,
so discard them and open-code the functionality.

The sigorsets() call isn't needed as or-ing with current->blocked is
exactly what sigprocmask(SIG_BLOCK) does.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   16 ---
 drivers/staging/lustre/lustre/include/lustre_lib.h |   21 +++-
 drivers/staging/lustre/lustre/llite/llite_mmap.c   |   14 -
 3 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index be40cf4fb44a..d9002e7424d4 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -93,22 +93,6 @@
 #define LNET_ACCEPTOR_MIN_RESERVED_PORT512
 #define LNET_ACCEPTOR_MAX_RESERVED_PORT1023
 
-/* Block all signals except for the @sigs */
-static inline void cfs_block_sigsinv(unsigned long sigs, sigset_t *old)
-{
-   sigset_t new;
-
-   siginitsetinv(, sigs);
-   sigorsets(, >blocked, );
-   sigprocmask(SIG_BLOCK, , old);
-}
-
-static inline void
-cfs_restore_sigs(sigset_t *old)
-{
-   sigprocmask(SIG_SETMASK, old, NULL);
-}
-
 struct libcfs_ioctl_handler {
struct list_head item;
int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h 
b/drivers/staging/lustre/lustre/include/lustre_lib.h
index 0053eafc1c10..eec10827f51f 100644
--- a/drivers/staging/lustre/lustre/include/lustre_lib.h
+++ b/drivers/staging/lustre/lustre/include/lustre_lib.h
@@ -94,31 +94,34 @@ static inline int l_fatal_signal_pending(struct task_struct 
*p)
  */
 #define l_wait_event_abortable(wq, condition)  \
 ({ \
-   sigset_t __old_blocked; \
+   sigset_t __new_blocked, __old_blocked;  \
int __ret = 0;  \
-   cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked);   \
+   siginitset(&__new_blocked, LUSTRE_FATAL_SIGS);  \
+   sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked); \
__ret = wait_event_interruptible(wq, condition);\
-   cfs_restore_sigs(&__old_blocked);   \
+   sigprocmask(SIG_SETMASK, &__old_blocked, NULL); \
__ret;  \
 })
 
 #define l_wait_event_abortable_timeout(wq, condition, timeout) \
 ({ \
-   sigset_t __old_blocked; \
+   sigset_t __new_blocked, __old_blocked;  \
int __ret = 0;  \
-   cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked);   \
+   siginitset(&__new_blocked, LUSTRE_FATAL_SIGS);  \
+   sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked); \
__ret = wait_event_interruptible_timeout(wq, condition, timeout);\
-   cfs_restore_sigs(&__old_blocked);   \
+   sigprocmask(SIG_SETMASK, &__old_blocked, NULL); \
__ret;  \
 })
 
 #define l_wait_event_abortable_exclusive(wq, condition)
\
 ({ \
-   sigset_t __old_blocked; \
+   sigset_t __new_blocked, __old_blocked;  \
int __ret = 0;  \
-   cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked);   \
+   siginitset(&__new_blocked, LUSTRE_FATAL_SIGS);  \
+   sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked); \
__ret = wait_event_interruptible_exclusive(wq, condition);  \
-   cfs_restore_sigs(&__old_blocked);   \
+   sigprocmask(SIG_SETMASK, &__old_blocked, NULL); \
__ret;  \
 })
 #endif /* _LUSTRE_LIB_H */
diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c 
b/drivers/staging/lustre/lustre/llite/llite_mmap.c
index 214b07554e62..d7fb5533f707 100644
--- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -152,7 +152,7 @@ static int ll_page_mkwrite0(struct 

[PATCH 10/30] staging: lustre: discard CFS_TICK

2018-05-20 Thread NeilBrown
This undocumented macro seems to represent "a small amount of time".
Sometimes it is used as-is, some times it is multiplied by 5 for no
obvious reason.
It does not appear that there is any connection between the different
places it is used - they all just want a short period for different
purposes and of different durarions.

So discard CFS_TICK and lets each use-site just use whatever number
of jiffies seems appropriate in that case.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |5 -
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h|2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c  |2 +-
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |2 +-
 5 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 084150e9d9ac..57d66aff546b 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -89,11 +89,6 @@
 
 #define LIBCFS_VERSION "0.7.0"
 
-/*
- * One jiffy
- */
-#define CFS_TICK   (1UL)
-
 /*
  * Lustre Error Checksum: calculates checksum
  * of Hex number by XORing each bit.
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index 570f54ed57b1..a0784167e989 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -58,7 +58,7 @@
 #define SOCKNAL_PEER_HASH_SIZE  101   /* # peer lists */
 #define SOCKNAL_RESCHED 100   /* # scheduler loops before reschedule */
 #define SOCKNAL_INSANITY_RECONN 5000  /* connd is trying on reconn infinitely 
*/
-#define SOCKNAL_ENOMEM_RETRYCFS_TICK /* jiffies between retries */
+#define SOCKNAL_ENOMEM_RETRY1 /* jiffies between retries */
 
 #define SOCKNAL_SINGLE_FRAG_TX  0 /* disable multi-fragment sends */
 #define SOCKNAL_SINGLE_FRAG_RX  0 /* disable multi-fragment receives */
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c 
b/drivers/staging/lustre/lustre/osc/osc_request.c
index 0155294184f1..0f355c415474 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -748,7 +748,7 @@ static int osc_should_shrink_grant(struct client_obd 
*client)
 OBD_CONNECT_GRANT_SHRINK) == 0)
return 0;
 
-   if (time_after_eq(time, next_shrink - 5 * CFS_TICK)) {
+   if (time_after_eq(time, next_shrink - 5)) {
/* Get the current RPC size directly, instead of going via:
 * cli_brw_size(obd->u.cli.cl_import->imp_obd->obd_self_export)
 * Keep comment here so that it can be found by searching.
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c 
b/drivers/staging/lustre/lustre/ptlrpc/import.c
index 537a9e2ed467..f704f8746f2c 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int 
noclose)
 
if (wait_event_idle_timeout(imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp),
-   max(timeout, CFS_TICK)) == 0)
+   max(timeout, 1UL)) == 0)
l_wait_event_abortable(
imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp));
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c 
b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 89eef8ec7df4..b3297b5ce395 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -180,7 +180,7 @@ static void ptlrpc_pinger_process_import(struct obd_import 
*imp,
 
imp->imp_force_verify = 0;
 
-   if (time_after_eq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
+   if (time_after_eq(imp->imp_next_ping - 5, this_ping) &&
!force) {
spin_unlock(>imp_lock);
return;




[PATCH 11/30] staging: lustre: move LERRCHKSUM() to libcfs_debug.h

2018-05-20 Thread NeilBrown
This macro is only used for debug messages, so use
it to the debug code.
Also improve the documentation slightly.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |7 ---
 .../lustre/include/linux/libcfs/libcfs_debug.h |7 +++
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 57d66aff546b..be40cf4fb44a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -89,13 +89,6 @@
 
 #define LIBCFS_VERSION "0.7.0"
 
-/*
- * Lustre Error Checksum: calculates checksum
- * of Hex number by XORing each bit.
- */
-#define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \
-  ((hexnum) >> 8 & 0xf))
-
 /* need both kernel and user-land acceptor */
 #define LNET_ACCEPTOR_MIN_RESERVED_PORT512
 #define LNET_ACCEPTOR_MAX_RESERVED_PORT1023
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index 0dc7b91efe7c..07f7d306ba9a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -165,6 +165,13 @@ do {   
\
__CDEBUG(, mask, format, ## __VA_ARGS__);  \
 } while (0)
 
+/*
+ * Lustre Error Checksum: calculates checksum
+ * of Hex number by XORing the nybbles.
+ */
+#define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \
+  ((hexnum) >> 8 & 0xf))
+
 #define CWARN(format, ...) CDEBUG_LIMIT(D_WARNING, format, ## __VA_ARGS__)
 #define CERROR(format, ...)CDEBUG_LIMIT(D_ERROR, format, ## __VA_ARGS__)
 #define CNETERR(format, a...)  CDEBUG_LIMIT(D_NETERROR, format, ## a)




[PATCH 12/30] staging: lustre: discard cfs_block_sigsinv()

2018-05-20 Thread NeilBrown
cfs_block_sigsinv() and cfs_restore_sigs() are simple
wrappers which save a couple of line of code and
hurt readability for people not familiar with them.
They aren't used often enough to be worthwhile,
so discard them and open-code the functionality.

The sigorsets() call isn't needed as or-ing with current->blocked is
exactly what sigprocmask(SIG_BLOCK) does.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   16 ---
 drivers/staging/lustre/lustre/include/lustre_lib.h |   21 +++-
 drivers/staging/lustre/lustre/llite/llite_mmap.c   |   14 -
 3 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index be40cf4fb44a..d9002e7424d4 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -93,22 +93,6 @@
 #define LNET_ACCEPTOR_MIN_RESERVED_PORT512
 #define LNET_ACCEPTOR_MAX_RESERVED_PORT1023
 
-/* Block all signals except for the @sigs */
-static inline void cfs_block_sigsinv(unsigned long sigs, sigset_t *old)
-{
-   sigset_t new;
-
-   siginitsetinv(, sigs);
-   sigorsets(, >blocked, );
-   sigprocmask(SIG_BLOCK, , old);
-}
-
-static inline void
-cfs_restore_sigs(sigset_t *old)
-{
-   sigprocmask(SIG_SETMASK, old, NULL);
-}
-
 struct libcfs_ioctl_handler {
struct list_head item;
int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h 
b/drivers/staging/lustre/lustre/include/lustre_lib.h
index 0053eafc1c10..eec10827f51f 100644
--- a/drivers/staging/lustre/lustre/include/lustre_lib.h
+++ b/drivers/staging/lustre/lustre/include/lustre_lib.h
@@ -94,31 +94,34 @@ static inline int l_fatal_signal_pending(struct task_struct 
*p)
  */
 #define l_wait_event_abortable(wq, condition)  \
 ({ \
-   sigset_t __old_blocked; \
+   sigset_t __new_blocked, __old_blocked;  \
int __ret = 0;  \
-   cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked);   \
+   siginitset(&__new_blocked, LUSTRE_FATAL_SIGS);  \
+   sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked); \
__ret = wait_event_interruptible(wq, condition);\
-   cfs_restore_sigs(&__old_blocked);   \
+   sigprocmask(SIG_SETMASK, &__old_blocked, NULL); \
__ret;  \
 })
 
 #define l_wait_event_abortable_timeout(wq, condition, timeout) \
 ({ \
-   sigset_t __old_blocked; \
+   sigset_t __new_blocked, __old_blocked;  \
int __ret = 0;  \
-   cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked);   \
+   siginitset(&__new_blocked, LUSTRE_FATAL_SIGS);  \
+   sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked); \
__ret = wait_event_interruptible_timeout(wq, condition, timeout);\
-   cfs_restore_sigs(&__old_blocked);   \
+   sigprocmask(SIG_SETMASK, &__old_blocked, NULL); \
__ret;  \
 })
 
 #define l_wait_event_abortable_exclusive(wq, condition)
\
 ({ \
-   sigset_t __old_blocked; \
+   sigset_t __new_blocked, __old_blocked;  \
int __ret = 0;  \
-   cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked);   \
+   siginitset(&__new_blocked, LUSTRE_FATAL_SIGS);  \
+   sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked); \
__ret = wait_event_interruptible_exclusive(wq, condition);  \
-   cfs_restore_sigs(&__old_blocked);   \
+   sigprocmask(SIG_SETMASK, &__old_blocked, NULL); \
__ret;  \
 })
 #endif /* _LUSTRE_LIB_H */
diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c 
b/drivers/staging/lustre/lustre/llite/llite_mmap.c
index 214b07554e62..d7fb5533f707 100644
--- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -152,7 +152,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, 

[PATCH 10/30] staging: lustre: discard CFS_TICK

2018-05-20 Thread NeilBrown
This undocumented macro seems to represent "a small amount of time".
Sometimes it is used as-is, some times it is multiplied by 5 for no
obvious reason.
It does not appear that there is any connection between the different
places it is used - they all just want a short period for different
purposes and of different durarions.

So discard CFS_TICK and lets each use-site just use whatever number
of jiffies seems appropriate in that case.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |5 -
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h|2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c  |2 +-
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |2 +-
 5 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 084150e9d9ac..57d66aff546b 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -89,11 +89,6 @@
 
 #define LIBCFS_VERSION "0.7.0"
 
-/*
- * One jiffy
- */
-#define CFS_TICK   (1UL)
-
 /*
  * Lustre Error Checksum: calculates checksum
  * of Hex number by XORing each bit.
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index 570f54ed57b1..a0784167e989 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -58,7 +58,7 @@
 #define SOCKNAL_PEER_HASH_SIZE  101   /* # peer lists */
 #define SOCKNAL_RESCHED 100   /* # scheduler loops before reschedule */
 #define SOCKNAL_INSANITY_RECONN 5000  /* connd is trying on reconn infinitely 
*/
-#define SOCKNAL_ENOMEM_RETRYCFS_TICK /* jiffies between retries */
+#define SOCKNAL_ENOMEM_RETRY1 /* jiffies between retries */
 
 #define SOCKNAL_SINGLE_FRAG_TX  0 /* disable multi-fragment sends */
 #define SOCKNAL_SINGLE_FRAG_RX  0 /* disable multi-fragment receives */
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c 
b/drivers/staging/lustre/lustre/osc/osc_request.c
index 0155294184f1..0f355c415474 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -748,7 +748,7 @@ static int osc_should_shrink_grant(struct client_obd 
*client)
 OBD_CONNECT_GRANT_SHRINK) == 0)
return 0;
 
-   if (time_after_eq(time, next_shrink - 5 * CFS_TICK)) {
+   if (time_after_eq(time, next_shrink - 5)) {
/* Get the current RPC size directly, instead of going via:
 * cli_brw_size(obd->u.cli.cl_import->imp_obd->obd_self_export)
 * Keep comment here so that it can be found by searching.
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c 
b/drivers/staging/lustre/lustre/ptlrpc/import.c
index 537a9e2ed467..f704f8746f2c 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int 
noclose)
 
if (wait_event_idle_timeout(imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp),
-   max(timeout, CFS_TICK)) == 0)
+   max(timeout, 1UL)) == 0)
l_wait_event_abortable(
imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp));
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c 
b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 89eef8ec7df4..b3297b5ce395 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -180,7 +180,7 @@ static void ptlrpc_pinger_process_import(struct obd_import 
*imp,
 
imp->imp_force_verify = 0;
 
-   if (time_after_eq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
+   if (time_after_eq(imp->imp_next_ping - 5, this_ping) &&
!force) {
spin_unlock(>imp_lock);
return;




[PATCH 11/30] staging: lustre: move LERRCHKSUM() to libcfs_debug.h

2018-05-20 Thread NeilBrown
This macro is only used for debug messages, so use
it to the debug code.
Also improve the documentation slightly.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |7 ---
 .../lustre/include/linux/libcfs/libcfs_debug.h |7 +++
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 57d66aff546b..be40cf4fb44a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -89,13 +89,6 @@
 
 #define LIBCFS_VERSION "0.7.0"
 
-/*
- * Lustre Error Checksum: calculates checksum
- * of Hex number by XORing each bit.
- */
-#define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \
-  ((hexnum) >> 8 & 0xf))
-
 /* need both kernel and user-land acceptor */
 #define LNET_ACCEPTOR_MIN_RESERVED_PORT512
 #define LNET_ACCEPTOR_MAX_RESERVED_PORT1023
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index 0dc7b91efe7c..07f7d306ba9a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -165,6 +165,13 @@ do {   
\
__CDEBUG(, mask, format, ## __VA_ARGS__);  \
 } while (0)
 
+/*
+ * Lustre Error Checksum: calculates checksum
+ * of Hex number by XORing the nybbles.
+ */
+#define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \
+  ((hexnum) >> 8 & 0xf))
+
 #define CWARN(format, ...) CDEBUG_LIMIT(D_WARNING, format, ## __VA_ARGS__)
 #define CERROR(format, ...)CDEBUG_LIMIT(D_ERROR, format, ## __VA_ARGS__)
 #define CNETERR(format, a...)  CDEBUG_LIMIT(D_NETERROR, format, ## a)




[PATCH 08/30] staging: lustre: discard cfs_cap_t, use kernel_cap_t

2018-05-20 Thread NeilBrown
lustre only sends 32bits of capabilities in on-the-wire RPC calls.
It current strips off higher bits and uses a 32bit cfs_cap_t
throughout.
Though there is a small memory cost, it is cleaner to use
kernel_cap_t throughout and only truncate when marshalling
data for RPC calls.

So this patch replaces cfs_cap_t with kernel_cap_t throughout,
and where a cfs_cap_t was previous stored in a __u32, we now
store cap.cap[0] instead.

With this, we can remove include/linux/libcfs/curproc.h

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |   69 
 .../staging/lustre/include/linux/libcfs/libcfs.h   |1 
 drivers/staging/lustre/lustre/include/obd.h|4 +
 drivers/staging/lustre/lustre/include/obd_class.h  |2 -
 drivers/staging/lustre/lustre/llite/dir.c  |2 -
 drivers/staging/lustre/lustre/llite/llite_lib.c|2 -
 drivers/staging/lustre/lustre/llite/namei.c|2 -
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|8 +-
 drivers/staging/lustre/lustre/mdc/mdc_internal.h   |4 +
 drivers/staging/lustre/lustre/mdc/mdc_lib.c|   17 +++--
 drivers/staging/lustre/lustre/mdc/mdc_reint.c  |2 -
 drivers/staging/lustre/lustre/mdc/mdc_request.c|2 -
 drivers/staging/lustre/lustre/ptlrpc/sec.c |2 -
 13 files changed, 24 insertions(+), 93 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/curproc.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h 
b/drivers/staging/lustre/include/linux/libcfs/curproc.h
deleted file mode 100644
index fc6f6eb2d5fe..
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/curproc.h
- *
- * Lustre curproc API declaration
- *
- * Author: Nikita Danilov 
- */
-
-#ifndef __LIBCFS_CURPROC_H__
-#define __LIBCFS_CURPROC_H__
-
-/*
- * Plus, platform-specific constant
- *
- * and opaque scalar type
- *
- * kernel_cap_t
- */
-
-typedef u32 cfs_cap_t;
-
-static inline cfs_cap_t cfs_curproc_cap_pack(void)
-{
-   /* cfs_cap_t is only the first word of kernel_cap_t */
-   return (cfs_cap_t)(current_cap().cap[0]);
-}
-
-/* __LIBCFS_CURPROC_H__ */
-#endif
-/*
- * Local variables:
- * c-indentation-style: "K"
- * c-basic-offset: 8
- * tab-width: 8
- * fill-column: 80
- * scroll-step: 1
- * End:
- */
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 4c91ef45abb6..7259544e4c32 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -86,7 +86,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #define LIBCFS_VERSION "0.7.0"
 
diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index fe21987a3f9f..da99a0f02b6c 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -717,7 +717,7 @@ struct md_op_data {
__u32  op_suppgids[2];
__u32  op_fsuid;
__u32  op_fsgid;
-   cfs_cap_t  op_cap;
+   kernel_cap_t   op_cap;
void   *op_data;
size_t  op_data_size;
 
@@ -912,7 +912,7 @@ struct md_ops {
 struct md_open_data *, struct ptlrpc_request **);
int (*create)(struct obd_export *, struct md_op_data *,
  const void *, size_t, umode_t, uid_t, gid_t,
- cfs_cap_t, __u64, struct ptlrpc_request **);
+ kernel_cap_t, __u64, struct ptlrpc_request **);
int (*enqueue)(struct obd_export *, struct ldlm_enqueue_info *,

[PATCH 09/30] staging: lustre: discard LOWEST_BIT_SET()

2018-05-20 Thread NeilBrown
This macro is only used once to test if a value is
a power of two.  So use is_power_of_2() instead and
discard the macro.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |2 --
 drivers/staging/lustre/lnet/lnet/lib-eq.c  |2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 7259544e4c32..084150e9d9ac 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -89,8 +89,6 @@
 
 #define LIBCFS_VERSION "0.7.0"
 
-#define LOWEST_BIT_SET(x)   ((x) & ~((x) - 1))
-
 /*
  * One jiffy
  */
diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c 
b/drivers/staging/lustre/lnet/lnet/lib-eq.c
index ea53b5cb3f72..c78e70373ab4 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-eq.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c
@@ -225,7 +225,7 @@ lnet_eq_enqueue_event(struct lnet_eq *eq, struct lnet_event 
*ev)
lnet_eq_wait_lock();
ev->sequence = eq->eq_enq_seq++;
 
-   LASSERT(eq->eq_size == LOWEST_BIT_SET(eq->eq_size));
+   LASSERT(is_power_of_2(eq->eq_size));
index = ev->sequence & (eq->eq_size - 1);
 
eq->eq_events[index] = *ev;




[PATCH 06/30] staging: lustre: remove current_pid() and current_comm()

2018-05-20 Thread NeilBrown
Just use current->pid and current->comm directly, instead
of having wrappers.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |4 
 drivers/staging/lustre/lnet/libcfs/debug.c |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |2 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |2 +-
 drivers/staging/lustre/lustre/llite/statahead.c|6 +++---
 drivers/staging/lustre/lustre/lov/lov_merge.c  |2 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c|6 +++---
 drivers/staging/lustre/lustre/obdclass/class_obd.c |2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +-
 drivers/staging/lustre/lustre/ptlrpc/client.c  |8 
 drivers/staging/lustre/lustre/ptlrpc/service.c |6 +++---
 11 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h 
b/drivers/staging/lustre/include/linux/libcfs/curproc.h
index d6e4f47b5daf..83526f84495d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
@@ -48,10 +48,6 @@
  * kernel_cap_t
  */
 
-/* check if task is running in compat mode.*/
-#define current_pid()  (current->pid)
-#define current_comm() (current->comm)
-
 typedef u32 cfs_cap_t;
 
 #define CFS_CAP_FS_MASK (BIT(CAP_CHOWN) |  \
diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c 
b/drivers/staging/lustre/lnet/libcfs/debug.c
index 5862f0730dd0..724a453a27ac 100644
--- a/drivers/staging/lustre/lnet/libcfs/debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/debug.c
@@ -373,7 +373,7 @@ void libcfs_debug_dumplog(void)
add_wait_queue(_ctlwq, );
 
dumper = kthread_run(libcfs_debug_dumplog_thread,
-(void *)(long)current_pid(),
+(void *)(long)current->pid,
 "libcfs_debug_dumper");
set_current_state(TASK_INTERRUPTIBLE);
if (IS_ERR(dumper))
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 22c49cc593e3..763acd2311a2 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1558,7 +1558,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace 
*ns,
 
lock->l_req_mode = mode;
lock->l_ast_data = data;
-   lock->l_pid = current_pid();
+   lock->l_pid = current->pid;
if (cbs) {
lock->l_blocking_ast = cbs->lcs_blocking;
lock->l_completion_ast = cbs->lcs_completion;
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h 
b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 6504850e3689..379d88e20cd3 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -1140,7 +1140,7 @@ dentry_may_statahead(struct inode *dir, struct dentry 
*dentry)
return false;
 
/* not the same process, don't statahead */
-   if (lli->lli_opendir_pid != current_pid())
+   if (lli->lli_opendir_pid != current->pid)
return false;
 
/*
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c 
b/drivers/staging/lustre/lustre/llite/statahead.c
index b4a6ee6c83f3..d864f5f36d85 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -1075,7 +1075,7 @@ static int ll_statahead_thread(void *arg)
CDEBUG(D_READA, "Statahead for dir " DFID " hit ratio 
too low: hit/miss %llu/%llu, sent/replied %llu/%llu, stopping statahead thread: 
pid %d\n",
   PFID(>lli_fid), sai->sai_hit,
   sai->sai_miss, sai->sai_sent,
-  sai->sai_replied, current_pid());
+  sai->sai_replied, current->pid);
break;
}
}
@@ -1147,7 +1147,7 @@ void ll_authorize_statahead(struct inode *dir, void *key)
 */
LASSERT(!lli->lli_opendir_pid);
lli->lli_opendir_key = key;
-   lli->lli_opendir_pid = current_pid();
+   lli->lli_opendir_pid = current->pid;
lli->lli_sa_enabled = 1;
}
spin_unlock(>lli_sa_lock);
@@ -1506,7 +1506,7 @@ static int start_statahead_thread(struct inode *dir, 
struct dentry *dentry)
atomic_inc(_i2sbi(parent->d_inode)->ll_sa_running);
 
CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %pd]\n",
-  current_pid(), parent);
+  current->pid, parent);
 
task = kthread_create(ll_statahead_thread, parent, "ll_sa_%u",
  lli->lli_opendir_pid);
diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c 

[PATCH 08/30] staging: lustre: discard cfs_cap_t, use kernel_cap_t

2018-05-20 Thread NeilBrown
lustre only sends 32bits of capabilities in on-the-wire RPC calls.
It current strips off higher bits and uses a 32bit cfs_cap_t
throughout.
Though there is a small memory cost, it is cleaner to use
kernel_cap_t throughout and only truncate when marshalling
data for RPC calls.

So this patch replaces cfs_cap_t with kernel_cap_t throughout,
and where a cfs_cap_t was previous stored in a __u32, we now
store cap.cap[0] instead.

With this, we can remove include/linux/libcfs/curproc.h

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |   69 
 .../staging/lustre/include/linux/libcfs/libcfs.h   |1 
 drivers/staging/lustre/lustre/include/obd.h|4 +
 drivers/staging/lustre/lustre/include/obd_class.h  |2 -
 drivers/staging/lustre/lustre/llite/dir.c  |2 -
 drivers/staging/lustre/lustre/llite/llite_lib.c|2 -
 drivers/staging/lustre/lustre/llite/namei.c|2 -
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|8 +-
 drivers/staging/lustre/lustre/mdc/mdc_internal.h   |4 +
 drivers/staging/lustre/lustre/mdc/mdc_lib.c|   17 +++--
 drivers/staging/lustre/lustre/mdc/mdc_reint.c  |2 -
 drivers/staging/lustre/lustre/mdc/mdc_request.c|2 -
 drivers/staging/lustre/lustre/ptlrpc/sec.c |2 -
 13 files changed, 24 insertions(+), 93 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/curproc.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h 
b/drivers/staging/lustre/include/linux/libcfs/curproc.h
deleted file mode 100644
index fc6f6eb2d5fe..
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/curproc.h
- *
- * Lustre curproc API declaration
- *
- * Author: Nikita Danilov 
- */
-
-#ifndef __LIBCFS_CURPROC_H__
-#define __LIBCFS_CURPROC_H__
-
-/*
- * Plus, platform-specific constant
- *
- * and opaque scalar type
- *
- * kernel_cap_t
- */
-
-typedef u32 cfs_cap_t;
-
-static inline cfs_cap_t cfs_curproc_cap_pack(void)
-{
-   /* cfs_cap_t is only the first word of kernel_cap_t */
-   return (cfs_cap_t)(current_cap().cap[0]);
-}
-
-/* __LIBCFS_CURPROC_H__ */
-#endif
-/*
- * Local variables:
- * c-indentation-style: "K"
- * c-basic-offset: 8
- * tab-width: 8
- * fill-column: 80
- * scroll-step: 1
- * End:
- */
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 4c91ef45abb6..7259544e4c32 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -86,7 +86,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #define LIBCFS_VERSION "0.7.0"
 
diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index fe21987a3f9f..da99a0f02b6c 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -717,7 +717,7 @@ struct md_op_data {
__u32  op_suppgids[2];
__u32  op_fsuid;
__u32  op_fsgid;
-   cfs_cap_t  op_cap;
+   kernel_cap_t   op_cap;
void   *op_data;
size_t  op_data_size;
 
@@ -912,7 +912,7 @@ struct md_ops {
 struct md_open_data *, struct ptlrpc_request **);
int (*create)(struct obd_export *, struct md_op_data *,
  const void *, size_t, umode_t, uid_t, gid_t,
- cfs_cap_t, __u64, struct ptlrpc_request **);
+ kernel_cap_t, __u64, struct ptlrpc_request **);
int (*enqueue)(struct obd_export *, struct ldlm_enqueue_info *,
   const union ldlm_policy_data *, 

[PATCH 09/30] staging: lustre: discard LOWEST_BIT_SET()

2018-05-20 Thread NeilBrown
This macro is only used once to test if a value is
a power of two.  So use is_power_of_2() instead and
discard the macro.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |2 --
 drivers/staging/lustre/lnet/lnet/lib-eq.c  |2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 7259544e4c32..084150e9d9ac 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -89,8 +89,6 @@
 
 #define LIBCFS_VERSION "0.7.0"
 
-#define LOWEST_BIT_SET(x)   ((x) & ~((x) - 1))
-
 /*
  * One jiffy
  */
diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c 
b/drivers/staging/lustre/lnet/lnet/lib-eq.c
index ea53b5cb3f72..c78e70373ab4 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-eq.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c
@@ -225,7 +225,7 @@ lnet_eq_enqueue_event(struct lnet_eq *eq, struct lnet_event 
*ev)
lnet_eq_wait_lock();
ev->sequence = eq->eq_enq_seq++;
 
-   LASSERT(eq->eq_size == LOWEST_BIT_SET(eq->eq_size));
+   LASSERT(is_power_of_2(eq->eq_size));
index = ev->sequence & (eq->eq_size - 1);
 
eq->eq_events[index] = *ev;




[PATCH 06/30] staging: lustre: remove current_pid() and current_comm()

2018-05-20 Thread NeilBrown
Just use current->pid and current->comm directly, instead
of having wrappers.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |4 
 drivers/staging/lustre/lnet/libcfs/debug.c |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |2 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |2 +-
 drivers/staging/lustre/lustre/llite/statahead.c|6 +++---
 drivers/staging/lustre/lustre/lov/lov_merge.c  |2 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c|6 +++---
 drivers/staging/lustre/lustre/obdclass/class_obd.c |2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +-
 drivers/staging/lustre/lustre/ptlrpc/client.c  |8 
 drivers/staging/lustre/lustre/ptlrpc/service.c |6 +++---
 11 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h 
b/drivers/staging/lustre/include/linux/libcfs/curproc.h
index d6e4f47b5daf..83526f84495d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
@@ -48,10 +48,6 @@
  * kernel_cap_t
  */
 
-/* check if task is running in compat mode.*/
-#define current_pid()  (current->pid)
-#define current_comm() (current->comm)
-
 typedef u32 cfs_cap_t;
 
 #define CFS_CAP_FS_MASK (BIT(CAP_CHOWN) |  \
diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c 
b/drivers/staging/lustre/lnet/libcfs/debug.c
index 5862f0730dd0..724a453a27ac 100644
--- a/drivers/staging/lustre/lnet/libcfs/debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/debug.c
@@ -373,7 +373,7 @@ void libcfs_debug_dumplog(void)
add_wait_queue(_ctlwq, );
 
dumper = kthread_run(libcfs_debug_dumplog_thread,
-(void *)(long)current_pid(),
+(void *)(long)current->pid,
 "libcfs_debug_dumper");
set_current_state(TASK_INTERRUPTIBLE);
if (IS_ERR(dumper))
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 22c49cc593e3..763acd2311a2 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1558,7 +1558,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace 
*ns,
 
lock->l_req_mode = mode;
lock->l_ast_data = data;
-   lock->l_pid = current_pid();
+   lock->l_pid = current->pid;
if (cbs) {
lock->l_blocking_ast = cbs->lcs_blocking;
lock->l_completion_ast = cbs->lcs_completion;
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h 
b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 6504850e3689..379d88e20cd3 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -1140,7 +1140,7 @@ dentry_may_statahead(struct inode *dir, struct dentry 
*dentry)
return false;
 
/* not the same process, don't statahead */
-   if (lli->lli_opendir_pid != current_pid())
+   if (lli->lli_opendir_pid != current->pid)
return false;
 
/*
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c 
b/drivers/staging/lustre/lustre/llite/statahead.c
index b4a6ee6c83f3..d864f5f36d85 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -1075,7 +1075,7 @@ static int ll_statahead_thread(void *arg)
CDEBUG(D_READA, "Statahead for dir " DFID " hit ratio 
too low: hit/miss %llu/%llu, sent/replied %llu/%llu, stopping statahead thread: 
pid %d\n",
   PFID(>lli_fid), sai->sai_hit,
   sai->sai_miss, sai->sai_sent,
-  sai->sai_replied, current_pid());
+  sai->sai_replied, current->pid);
break;
}
}
@@ -1147,7 +1147,7 @@ void ll_authorize_statahead(struct inode *dir, void *key)
 */
LASSERT(!lli->lli_opendir_pid);
lli->lli_opendir_key = key;
-   lli->lli_opendir_pid = current_pid();
+   lli->lli_opendir_pid = current->pid;
lli->lli_sa_enabled = 1;
}
spin_unlock(>lli_sa_lock);
@@ -1506,7 +1506,7 @@ static int start_statahead_thread(struct inode *dir, 
struct dentry *dentry)
atomic_inc(_i2sbi(parent->d_inode)->ll_sa_running);
 
CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %pd]\n",
-  current_pid(), parent);
+  current->pid, parent);
 
task = kthread_create(ll_statahead_thread, parent, "ll_sa_%u",
  lli->lli_opendir_pid);
diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c 

[PATCH 03/30] staging: lustre: move files out of lustre/lnet/libcfs/linux/

2018-05-20 Thread NeilBrown
There is no longer any value in having this separate
subdirectory, so promote the files in it.
Also tidy the Makefile a little to use the common "*-obj-y"
macro name.  This will allow individual files to be conditionally
compiled.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lnet/libcfs/Makefile|   17 -
 .../lustre/lnet/libcfs/linux-crypto-adler.c|  139 ++
 drivers/staging/lustre/lnet/libcfs/linux-crypto.c  |  445 
 drivers/staging/lustre/lnet/libcfs/linux-crypto.h  |   30 +
 drivers/staging/lustre/lnet/libcfs/linux-debug.c   |  144 ++
 .../staging/lustre/lnet/libcfs/linux-tracefile.c   |  257 
 .../lustre/lnet/libcfs/linux/linux-crypto-adler.c  |  139 --
 .../lustre/lnet/libcfs/linux/linux-crypto.c|  445 
 .../lustre/lnet/libcfs/linux/linux-crypto.h|   30 -
 .../staging/lustre/lnet/libcfs/linux/linux-debug.c |  144 --
 .../lustre/lnet/libcfs/linux/linux-tracefile.c |  257 
 11 files changed, 1023 insertions(+), 1024 deletions(-)
 create mode 100644 drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c
 create mode 100644 drivers/staging/lustre/lnet/libcfs/linux-crypto.c
 create mode 100644 drivers/staging/lustre/lnet/libcfs/linux-crypto.h
 create mode 100644 drivers/staging/lustre/lnet/libcfs/linux-debug.c
 create mode 100644 drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
 delete mode 100644 
drivers/staging/lustre/lnet/libcfs/linux/linux-crypto-adler.c
 delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c
 delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.h
 delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c
 delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c

diff --git a/drivers/staging/lustre/lnet/libcfs/Makefile 
b/drivers/staging/lustre/lnet/libcfs/Makefile
index e73515789a11..6335f909d22b 100644
--- a/drivers/staging/lustre/lnet/libcfs/Makefile
+++ b/drivers/staging/lustre/lnet/libcfs/Makefile
@@ -4,14 +4,13 @@ subdir-ccflags-y += 
-I$(srctree)/drivers/staging/lustre/lustre/include
 
 obj-$(CONFIG_LNET) += libcfs.o
 
-libcfs-linux-objs := linux-tracefile.o linux-debug.o
-libcfs-linux-objs += linux-crypto.o
-libcfs-linux-objs += linux-crypto-adler.o
+libcfs-obj-y += linux-tracefile.o linux-debug.o
+libcfs-obj-y += linux-crypto.o
+libcfs-obj-y += linux-crypto-adler.o
 
-libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs))
+libcfs-obj-y += debug.o fail.o module.o tracefile.o
+libcfs-obj-y += libcfs_string.o hash.o
+libcfs-obj-y += libcfs_cpu.o
+libcfs-obj-y += libcfs_mem.o libcfs_lock.o
 
-libcfs-all-objs := debug.o fail.o module.o tracefile.o \
-  libcfs_string.o hash.o \
-  libcfs_cpu.o libcfs_mem.o libcfs_lock.o
-
-libcfs-objs := $(libcfs-linux-objs) $(libcfs-all-objs)
+libcfs-objs := $(libcfs-obj-y)
diff --git a/drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c 
b/drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c
new file mode 100644
index ..db81ed527452
--- /dev/null
+++ b/drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c
@@ -0,0 +1,139 @@
+// SPDX-License-Identifier: GPL-2.0
+/* GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see http://www.gnu.org/licenses
+ *
+ * Please  visit http://www.xyratex.com/contact if you need additional
+ * information or have any questions.
+ *
+ * GPL HEADER END
+ */
+
+/*
+ * Copyright 2012 Xyratex Technology Limited
+ */
+
+/*
+ * This is crypto api shash wrappers to zlib_adler32.
+ */
+
+#include 
+#include 
+#include 
+#include "linux-crypto.h"
+
+#define CHKSUM_BLOCK_SIZE  1
+#define CHKSUM_DIGEST_SIZE 4
+
+static int adler32_cra_init(struct crypto_tfm *tfm)
+{
+   u32 *key = crypto_tfm_ctx(tfm);
+
+   *key = 1;
+
+   return 0;
+}
+
+static int adler32_setkey(struct crypto_shash *hash, const u8 *key,
+ unsigned int keylen)
+{
+   u32 *mctx = crypto_shash_ctx(hash);
+
+   if (keylen != sizeof(u32)) {
+   crypto_shash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN);
+   return -EINVAL;
+   }
+   *mctx = *(u32 *)key;
+   return 0;
+}
+
+static int adler32_init(struct shash_desc *desc)
+{

[PATCH 03/30] staging: lustre: move files out of lustre/lnet/libcfs/linux/

2018-05-20 Thread NeilBrown
There is no longer any value in having this separate
subdirectory, so promote the files in it.
Also tidy the Makefile a little to use the common "*-obj-y"
macro name.  This will allow individual files to be conditionally
compiled.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lnet/libcfs/Makefile|   17 -
 .../lustre/lnet/libcfs/linux-crypto-adler.c|  139 ++
 drivers/staging/lustre/lnet/libcfs/linux-crypto.c  |  445 
 drivers/staging/lustre/lnet/libcfs/linux-crypto.h  |   30 +
 drivers/staging/lustre/lnet/libcfs/linux-debug.c   |  144 ++
 .../staging/lustre/lnet/libcfs/linux-tracefile.c   |  257 
 .../lustre/lnet/libcfs/linux/linux-crypto-adler.c  |  139 --
 .../lustre/lnet/libcfs/linux/linux-crypto.c|  445 
 .../lustre/lnet/libcfs/linux/linux-crypto.h|   30 -
 .../staging/lustre/lnet/libcfs/linux/linux-debug.c |  144 --
 .../lustre/lnet/libcfs/linux/linux-tracefile.c |  257 
 11 files changed, 1023 insertions(+), 1024 deletions(-)
 create mode 100644 drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c
 create mode 100644 drivers/staging/lustre/lnet/libcfs/linux-crypto.c
 create mode 100644 drivers/staging/lustre/lnet/libcfs/linux-crypto.h
 create mode 100644 drivers/staging/lustre/lnet/libcfs/linux-debug.c
 create mode 100644 drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
 delete mode 100644 
drivers/staging/lustre/lnet/libcfs/linux/linux-crypto-adler.c
 delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c
 delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.h
 delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c
 delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c

diff --git a/drivers/staging/lustre/lnet/libcfs/Makefile 
b/drivers/staging/lustre/lnet/libcfs/Makefile
index e73515789a11..6335f909d22b 100644
--- a/drivers/staging/lustre/lnet/libcfs/Makefile
+++ b/drivers/staging/lustre/lnet/libcfs/Makefile
@@ -4,14 +4,13 @@ subdir-ccflags-y += 
-I$(srctree)/drivers/staging/lustre/lustre/include
 
 obj-$(CONFIG_LNET) += libcfs.o
 
-libcfs-linux-objs := linux-tracefile.o linux-debug.o
-libcfs-linux-objs += linux-crypto.o
-libcfs-linux-objs += linux-crypto-adler.o
+libcfs-obj-y += linux-tracefile.o linux-debug.o
+libcfs-obj-y += linux-crypto.o
+libcfs-obj-y += linux-crypto-adler.o
 
-libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs))
+libcfs-obj-y += debug.o fail.o module.o tracefile.o
+libcfs-obj-y += libcfs_string.o hash.o
+libcfs-obj-y += libcfs_cpu.o
+libcfs-obj-y += libcfs_mem.o libcfs_lock.o
 
-libcfs-all-objs := debug.o fail.o module.o tracefile.o \
-  libcfs_string.o hash.o \
-  libcfs_cpu.o libcfs_mem.o libcfs_lock.o
-
-libcfs-objs := $(libcfs-linux-objs) $(libcfs-all-objs)
+libcfs-objs := $(libcfs-obj-y)
diff --git a/drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c 
b/drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c
new file mode 100644
index ..db81ed527452
--- /dev/null
+++ b/drivers/staging/lustre/lnet/libcfs/linux-crypto-adler.c
@@ -0,0 +1,139 @@
+// SPDX-License-Identifier: GPL-2.0
+/* GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see http://www.gnu.org/licenses
+ *
+ * Please  visit http://www.xyratex.com/contact if you need additional
+ * information or have any questions.
+ *
+ * GPL HEADER END
+ */
+
+/*
+ * Copyright 2012 Xyratex Technology Limited
+ */
+
+/*
+ * This is crypto api shash wrappers to zlib_adler32.
+ */
+
+#include 
+#include 
+#include 
+#include "linux-crypto.h"
+
+#define CHKSUM_BLOCK_SIZE  1
+#define CHKSUM_DIGEST_SIZE 4
+
+static int adler32_cra_init(struct crypto_tfm *tfm)
+{
+   u32 *key = crypto_tfm_ctx(tfm);
+
+   *key = 1;
+
+   return 0;
+}
+
+static int adler32_setkey(struct crypto_shash *hash, const u8 *key,
+ unsigned int keylen)
+{
+   u32 *mctx = crypto_shash_ctx(hash);
+
+   if (keylen != sizeof(u32)) {
+   crypto_shash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN);
+   return -EINVAL;
+   }
+   *mctx = *(u32 *)key;
+   return 0;
+}
+
+static int adler32_init(struct shash_desc *desc)
+{
+   u32 

  1   2   3   4   5   6   7   >