* atomic operations @ 2013-02-24 9:42 Shraddha Kamat 2013-02-24 10:50 ` richard -rw- weinberger 2013-02-24 12:50 ` Peter Teoh 0 siblings, 2 replies; 7+ messages in thread From: Shraddha Kamat @ 2013-02-24 9:42 UTC (permalink / raw) To: kernelnewbies what is the relation between atomic operations and memory alignment ? I read from UTLK that "an unaligned memory access is not atomic" please explain me , I am not able to get the relationship between memory alignment and atomicity of the operation. ^ permalink raw reply [flat|nested] 7+ messages in thread
* atomic operations 2013-02-24 9:42 atomic operations Shraddha Kamat @ 2013-02-24 10:50 ` richard -rw- weinberger 2013-02-24 23:24 ` Valdis.Kletnieks at vt.edu 2013-02-24 12:50 ` Peter Teoh 1 sibling, 1 reply; 7+ messages in thread From: richard -rw- weinberger @ 2013-02-24 10:50 UTC (permalink / raw) To: kernelnewbies On Sun, Feb 24, 2013 at 10:42 AM, Shraddha Kamat <sh2008ka@gmail.com> wrote: > what is the relation between atomic operations and memory alignment ? > > I read from UTLK that "an unaligned memory access is not atomic" > > please explain me , I am not able to get the relationship between > memory alignment and atomicity of the operation. Not all CPUs support unaligned memory access, such an access may cause a fault which needs to be fixed by the kernel... -- Thanks, //richard ^ permalink raw reply [flat|nested] 7+ messages in thread
* atomic operations 2013-02-24 10:50 ` richard -rw- weinberger @ 2013-02-24 23:24 ` Valdis.Kletnieks at vt.edu 0 siblings, 0 replies; 7+ messages in thread From: Valdis.Kletnieks at vt.edu @ 2013-02-24 23:24 UTC (permalink / raw) To: kernelnewbies On Sun, 24 Feb 2013 11:50:14 +0100, richard -rw- weinberger said: > On Sun, Feb 24, 2013 at 10:42 AM, Shraddha Kamat <sh2008ka@gmail.com> wrote: > > what is the relation between atomic operations and memory alignment ? > > > > I read from UTLK that "an unaligned memory access is not atomic" > > > > please explain me , I am not able to get the relationship between > > memory alignment and atomicity of the operation. > > Not all CPUs support unaligned memory access, such an access may cause a fault > which needs to be fixed by the kernel... There's a more subtle issue - an unaligned access can be split across a cache line boundary, requiring 2 separate memory accesses to do the read or write. This can result in CPU A fetching the first half of the variable, CPU B updating both halves, and then A fetching the second half of the now updated variable.. This can bite you even on CPUs that support unaligned accesses. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 865 bytes Desc: not available Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130224/d2bc34b0/attachment.bin ^ permalink raw reply [flat|nested] 7+ messages in thread
* atomic operations 2013-02-24 9:42 atomic operations Shraddha Kamat 2013-02-24 10:50 ` richard -rw- weinberger @ 2013-02-24 12:50 ` Peter Teoh 2013-02-24 12:53 ` Peter Teoh 2013-03-01 5:44 ` Arun KS 1 sibling, 2 replies; 7+ messages in thread From: Peter Teoh @ 2013-02-24 12:50 UTC (permalink / raw) To: kernelnewbies in simple terms, any operation, in terms assembly instructions, which can be executed in ONE instruction, is "atomic", because, just like an atom, it cannot be broken up into parts. any instructions that is longer than one, for eg, TWO instruction, is NOT atomic, because in BETWEEN the first and 2nd instruction, something like an interrupt can come in, and affect the values of the operand when it is passed from instruction one to second instruction. To save me from reiteration: http://www.ibm.com/developerworks/library/pa-dalign/ (search for "atomicity"). http://stackoverflow.com/questions/381244/purpose-of-memory-alignment http://lwn.net/Articles/260832/ http://www.songho.ca/misc/alignment/dataalign.html http://www.cis.upenn.edu/~palsetia/cit595s08/Lectures08/alignmentOrdering.pdf Essentially, atomicity and non-alignment become problematic when u tried to to read using non-byte addressing mode with non-aligned address. On Sun, Feb 24, 2013 at 5:42 PM, Shraddha Kamat <sh2008ka@gmail.com> wrote: > what is the relation between atomic operations and memory alignment ? > > I read from UTLK that "an unaligned memory access is not atomic" > > please explain me , I am not able to get the relationship between > memory alignment and atomicity of the operation. > > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > -- Regards, Peter Teoh -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130224/36c27526/attachment.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* atomic operations 2013-02-24 12:50 ` Peter Teoh @ 2013-02-24 12:53 ` Peter Teoh 2013-02-25 7:15 ` Kumar amit mehta 2013-03-01 5:44 ` Arun KS 1 sibling, 1 reply; 7+ messages in thread From: Peter Teoh @ 2013-02-24 12:53 UTC (permalink / raw) To: kernelnewbies Another good article on atomicty and data sizes: http://www.ibm.com/developerworks/library/pa-atom/ On Sun, Feb 24, 2013 at 8:50 PM, Peter Teoh <htmldeveloper@gmail.com> wrote: > in simple terms, any operation, in terms assembly instructions, which can > be executed in ONE instruction, is "atomic", because, just like an atom, it > cannot be broken up into parts. any instructions that is longer than one, > for eg, TWO instruction, is NOT atomic, because in BETWEEN the first and > 2nd instruction, something like an interrupt can come in, and affect the > values of the operand when it is passed from instruction one to second > instruction. To save me from reiteration: > > http://www.ibm.com/developerworks/library/pa-dalign/ (search for > "atomicity"). > > http://stackoverflow.com/questions/381244/purpose-of-memory-alignment > > http://lwn.net/Articles/260832/ > > http://www.songho.ca/misc/alignment/dataalign.html > > > http://www.cis.upenn.edu/~palsetia/cit595s08/Lectures08/alignmentOrdering.pdf > > Essentially, atomicity and non-alignment become problematic when u tried > to to read using non-byte addressing mode with non-aligned address. > > On Sun, Feb 24, 2013 at 5:42 PM, Shraddha Kamat <sh2008ka@gmail.com>wrote: > >> what is the relation between atomic operations and memory alignment ? >> >> I read from UTLK that "an unaligned memory access is not atomic" >> >> please explain me , I am not able to get the relationship between >> memory alignment and atomicity of the operation. >> >> >> _______________________________________________ >> Kernelnewbies mailing list >> Kernelnewbies at kernelnewbies.org >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >> > > > > -- > Regards, > Peter Teoh > -- Regards, Peter Teoh -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130224/c982b31a/attachment.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* atomic operations 2013-02-24 12:53 ` Peter Teoh @ 2013-02-25 7:15 ` Kumar amit mehta 0 siblings, 0 replies; 7+ messages in thread From: Kumar amit mehta @ 2013-02-25 7:15 UTC (permalink / raw) To: kernelnewbies On Sun, Feb 24, 2013 at 08:53:20PM +0800, Peter Teoh wrote: > Another good article on atomicty and data sizes: > > http://www.ibm.com/developerworks/library/pa-atom/ > > On Sun, Feb 24, 2013 at 8:50 PM, Peter Teoh <htmldeveloper@gmail.com> wrote: > > > in simple terms, any operation, in terms assembly instructions, which can > > be executed in ONE instruction, is "atomic", because, just like an atom, it > > cannot be broken up into parts. any instructions that is longer than one, > > for eg, TWO instruction, is NOT atomic, because in BETWEEN the first and > > 2nd instruction, something like an interrupt can come in, and affect the > > values of the operand when it is passed from instruction one to second > > instruction. To save me from reiteration: > > > > http://www.ibm.com/developerworks/library/pa-dalign/ (search for > > "atomicity"). > > > > http://stackoverflow.com/questions/381244/purpose-of-memory-alignment > > > > http://lwn.net/Articles/260832/ > > > > http://www.songho.ca/misc/alignment/dataalign.html > > > > > > http://www.cis.upenn.edu/~palsetia/cit595s08/Lectures08/alignmentOrdering.pdf > > > > Essentially, atomicity and non-alignment become problematic when u tried > > to to read using non-byte addressing mode with non-aligned address. > > > > On Sun, Feb 24, 2013 at 5:42 PM, Shraddha Kamat <sh2008ka@gmail.com>wrote: > > > >> what is the relation between atomic operations and memory alignment ? > >> > >> I read from UTLK that "an unaligned memory access is not atomic" > >> > >> please explain me , I am not able to get the relationship between > >> memory alignment and atomicity of the operation. It seems for this same reason, every objects of a struct page is organized as double word. <snip from linux/mm_types.h> * The objects in struct page are organized in double word blocks in * order to allows us to use atomic double word operations on portions * of struct page. That is currently only used by slub but the arrangement * allows the use of atomic double word operations on the flags/mapping * and lru list pointers also. <snip from linux/mm_types.h> -Amit ^ permalink raw reply [flat|nested] 7+ messages in thread
* atomic operations 2013-02-24 12:50 ` Peter Teoh 2013-02-24 12:53 ` Peter Teoh @ 2013-03-01 5:44 ` Arun KS 1 sibling, 0 replies; 7+ messages in thread From: Arun KS @ 2013-03-01 5:44 UTC (permalink / raw) To: kernelnewbies Hi Peter, On Sun, Feb 24, 2013 at 6:20 PM, Peter Teoh <htmldeveloper@gmail.com> wrote: > in simple terms, any operation, in terms assembly instructions, which can be > executed in ONE instruction, is "atomic", because, just like an atom, it > cannot be broken up into parts. any instructions that is longer than one, > for eg, TWO instruction, is NOT atomic, because in BETWEEN the first and 2nd > instruction, something like an interrupt can come in, and affect the values > of the operand when it is passed from instruction one to second instruction. Nice explanation. Thanks, Arun > To save me from reiteration: > > http://www.ibm.com/developerworks/library/pa-dalign/ (search for > "atomicity"). > > http://stackoverflow.com/questions/381244/purpose-of-memory-alignment > > http://lwn.net/Articles/260832/ > > http://www.songho.ca/misc/alignment/dataalign.html > > http://www.cis.upenn.edu/~palsetia/cit595s08/Lectures08/alignmentOrdering.pdf > > Essentially, atomicity and non-alignment become problematic when u tried to > to read using non-byte addressing mode with non-aligned address. > > On Sun, Feb 24, 2013 at 5:42 PM, Shraddha Kamat <sh2008ka@gmail.com> wrote: >> >> what is the relation between atomic operations and memory alignment ? >> >> I read from UTLK that "an unaligned memory access is not atomic" >> >> please explain me , I am not able to get the relationship between >> memory alignment and atomicity of the operation. >> >> >> _______________________________________________ >> Kernelnewbies mailing list >> Kernelnewbies at kernelnewbies.org >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > > > > -- > Regards, > Peter Teoh > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-03-01 5:44 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-02-24 9:42 atomic operations Shraddha Kamat 2013-02-24 10:50 ` richard -rw- weinberger 2013-02-24 23:24 ` Valdis.Kletnieks at vt.edu 2013-02-24 12:50 ` Peter Teoh 2013-02-24 12:53 ` Peter Teoh 2013-02-25 7:15 ` Kumar amit mehta 2013-03-01 5:44 ` Arun KS
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).