linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: linux-c-programming@vger.kernel.org
Subject: About the memory ordering and function call
Date: Wed, 05 Feb 2014 09:23:35 +0800	[thread overview]
Message-ID: <52F19297.9070703@cn.fujitsu.com> (raw)

Hi,

Notsure it's suitable to ask here,but a strange memory order related
problem happens.
Related codes are like below (somewhat simplified)

------
struct my_work {
/* someunrelated variants */
struct SOME_OTHER_STRUCT *my_pointer; <<< Attention here
struct work_struct normal_work;
};

void my_queue_work(struct workqueue_struct *wq, <<< wq is WQ_UNBOUND
workqueue
struct my_work *work)
{
/*
* the work->normal_work is initialized somewhere else,
* and the work job will use the work->my_pointer.
*/

work->my_pointer = something; <<< The problem
/* Do something else */
queue_work(wq, work->normal_work);
}
------

The codes runs fine on all my *INTEL* boxes but kernel panic on *AMD*
boxes(othertesters', so I can't reproduce it),
when the work is executed, a NULL pointer exception will happen.
After tracing the backtrace,it happens that the work->my_pointer is not
set to proper address and isstill NULL.

So I have some questionsabout the problem.
1) Should I add an smp_mb() behind "work->my_pointer = something"?

2) Why the smp_mb() in queue_work() function can't ensure
"work->my_pointer" is set?
More accuratly, will smp_mb() affect outside of a function call?
Forreference, the smp_mb() lies like below:
queue_work()
queue_work_on()
__queue_work()
insert_work()
smp_mb()

3) Why INTEL CPUs can't trigger the problem?
Wikipedia says that AMD CPUs has somewhat weak memory ordering than
Intel, may it be the problem?

Thanks,
Qu

             reply	other threads:[~2014-02-05  1:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-05  1:23 Qu Wenruo [this message]
2014-02-05  5:14 ` About the memory ordering and function call Hendrik Visage

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=52F19297.9070703@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=linux-c-programming@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).