All of lore.kernel.org
 help / color / mirror / Atom feed
From: "xiaofeng.yan" <xiaofeng.yan2012@gmail.com>
To: willy@infradead.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, dledford@redhat.com, jgg@ziepe.ca,
	oulijun@huawei.com, yanxiaofeng7@jd.com,
	xiaofeng.yan2012@gmail.com
Subject: [PATCH 1/2] [xarry]:Fixed an issue with memory allocated using the GFP_KERNEL flag in spinlocks
Date: Wed,  4 Nov 2020 10:32:12 +0800	[thread overview]
Message-ID: <20201104023213.760-1-xiaofeng.yan2012@gmail.com> (raw)

From: "xiaofeng.yan" <yanxiaofeng7@jd.com>

function xa_store_irq() has a spinlock as follows:
 xa_lock_irq()
   -->spin_lock_irq(&(xa)->xa_lock)
GFP_KERNEL flag could cause sleep.
So change GFP_KERNEL to  GFP_ATOMIC and Romve "gfp_t gfp" in function
static inline void *xa_store_irq(struct xarray *xa, unsigned long index,
                void *entry, gfp_t gfp)

Signed-off-by: xiaofeng.yan <yanxiaofeng7@jd.com>
---
 include/linux/xarray.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index 92c0160b3352..aeaf97d5642f 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -595,7 +595,6 @@ static inline void *xa_store_bh(struct xarray *xa, unsigned long index,
  * @xa: XArray.
  * @index: Index into array.
  * @entry: New entry.
- * @gfp: Memory allocation flags.
  *
  * This function is like calling xa_store() except it disables interrupts
  * while holding the array lock.
@@ -605,12 +604,12 @@ static inline void *xa_store_bh(struct xarray *xa, unsigned long index,
  * Return: The old entry at this index or xa_err() if an error happened.
  */
 static inline void *xa_store_irq(struct xarray *xa, unsigned long index,
-		void *entry, gfp_t gfp)
+		void *entry)
 {
 	void *curr;
 
 	xa_lock_irq(xa);
-	curr = __xa_store(xa, index, entry, gfp);
+	curr = __xa_store(xa, index, entry, GFP_ATOMIC);
 	xa_unlock_irq(xa);
 
 	return curr;
-- 
2.17.1


             reply	other threads:[~2020-11-04  2:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04  2:32 xiaofeng.yan [this message]
2020-11-04  2:32 ` [PATCH 2/2] infiniband: Modify the reference to xa_store_irq() because the parameter of this function has changed xiaofeng.yan
2020-11-04 18:58   ` Jason Gunthorpe
2020-11-04 19:30     ` Matthew Wilcox
2020-11-04 21:34       ` Jason Gunthorpe
2020-11-04  2:36 ` [PATCH 1/2] [xarry]:Fixed an issue with memory allocated using the GFP_KERNEL flag in spinlocks Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201104023213.760-1-xiaofeng.yan2012@gmail.com \
    --to=xiaofeng.yan2012@gmail.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oulijun@huawei.com \
    --cc=willy@infradead.org \
    --cc=yanxiaofeng7@jd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.