All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xianting TIan <xianting.tian@linux.alibaba.com>
To: Jiri Slaby <jirislaby@kernel.org>,
	gregkh@linuxfoundation.org, amit@kernel.org, arnd@arndb.de,
	osandov@fb.com
Cc: clang-built-linux@googlegroups.com, kbuild-all@lists.01.org,
	linuxppc-dev@lists.ozlabs.org,
	virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 1/2] tty: hvc: pass DMA capable memory to put_chars()
Date: Sat, 14 Aug 2021 00:07:03 +0800	[thread overview]
Message-ID: <9f6b0b31-b2fd-0706-b40f-d7ffc5c48737@linux.alibaba.com> (raw)
In-Reply-To: <0c808001-7643-fdcf-66ba-738654ec0c21@kernel.org>


在 2021/8/13 下午1:53, Jiri Slaby 写道:
> Hi,
>
> On 12. 08. 21, 14:26, kernel test robot wrote:
>>>> drivers/tty/hvc/hvc_console.c:190:26: warning: variable 'hp' is 
>>>> uninitialized when used here [-Wuninitialized]
>>             spin_unlock_irqrestore(&hp->c_lock, flags);
>>                                     ^~
>>     drivers/tty/hvc/hvc_console.c:149:23: note: initialize the 
>> variable 'hp' to silence this warning
>>             struct hvc_struct *hp;
>>                                  ^
>>                                   = NULL
>
> So you clearly didn't test your change as it would crash quite 
> instantly. I wonder, where do you intend to get hp from in the 
> console::print() hook?
>
> thanks,
According to analysis, this issue may can be solved just by adjust the 
alignment to L1_CACHE_BYTES: 

#define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES)))

Our analysis as below, the original __ALIGNED__ is sizeof(long) which is 
8 for 64bit cpu.
char c[N_OUTBUF] __ALIGNED__; //c[16] __ALIGNED__;

For 4K page, c[16] may cross the page when alignemnt is 8.

In the case the physical address of c[16] is noncontiguous.
|------8----|..........|-----8-----|    PAGE_1
..........................|-----------16----------| c[16]

.........................................|-----8-----|.............|-----8-----| 
PAGE_2
But when the alignment is L1_CACHE_BYTES(eg, 64), or at least 
N_OUTBUF(16), we have no dma issue as c[16] won't cross the page, the 
physical address of c[16] is contiguous.
|--------64--------|.........|--------64---------| PAGE_3

..................................|--c[16]--|

Could you help comments this?  thanks


WARNING: multiple messages have this Message-ID (diff)
From: Xianting TIan <xianting.tian@linux.alibaba.com>
To: Jiri Slaby <jirislaby@kernel.org>,
	gregkh@linuxfoundation.org, amit@kernel.org, arnd@arndb.de,
	osandov@fb.com
Cc: clang-built-linux@googlegroups.com, kbuild-all@lists.01.org,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v6 1/2] tty: hvc: pass DMA capable memory to put_chars()
Date: Sat, 14 Aug 2021 00:07:03 +0800	[thread overview]
Message-ID: <9f6b0b31-b2fd-0706-b40f-d7ffc5c48737@linux.alibaba.com> (raw)
In-Reply-To: <0c808001-7643-fdcf-66ba-738654ec0c21@kernel.org>


在 2021/8/13 下午1:53, Jiri Slaby 写道:
> Hi,
>
> On 12. 08. 21, 14:26, kernel test robot wrote:
>>>> drivers/tty/hvc/hvc_console.c:190:26: warning: variable 'hp' is 
>>>> uninitialized when used here [-Wuninitialized]
>>             spin_unlock_irqrestore(&hp->c_lock, flags);
>>                                     ^~
>>     drivers/tty/hvc/hvc_console.c:149:23: note: initialize the 
>> variable 'hp' to silence this warning
>>             struct hvc_struct *hp;
>>                                  ^
>>                                   = NULL
>
> So you clearly didn't test your change as it would crash quite 
> instantly. I wonder, where do you intend to get hp from in the 
> console::print() hook?
>
> thanks,
According to analysis, this issue may can be solved just by adjust the 
alignment to L1_CACHE_BYTES: 

#define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES)))

Our analysis as below, the original __ALIGNED__ is sizeof(long) which is 
8 for 64bit cpu.
char c[N_OUTBUF] __ALIGNED__; //c[16] __ALIGNED__;

For 4K page, c[16] may cross the page when alignemnt is 8.

In the case the physical address of c[16] is noncontiguous.
|------8----|..........|-----8-----|    PAGE_1
..........................|-----------16----------| c[16]

.........................................|-----8-----|.............|-----8-----| 
PAGE_2
But when the alignment is L1_CACHE_BYTES(eg, 64), or at least 
N_OUTBUF(16), we have no dma issue as c[16] won't cross the page, the 
physical address of c[16] is contiguous.
|--------64--------|.........|--------64---------| PAGE_3

..................................|--c[16]--|

Could you help comments this?  thanks


WARNING: multiple messages have this Message-ID (diff)
From: Xianting TIan <xianting.tian@linux.alibaba.com>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH v6 1/2] tty: hvc: pass DMA capable memory to put_chars()
Date: Sat, 14 Aug 2021 00:07:03 +0800	[thread overview]
Message-ID: <9f6b0b31-b2fd-0706-b40f-d7ffc5c48737@linux.alibaba.com> (raw)
In-Reply-To: <0c808001-7643-fdcf-66ba-738654ec0c21@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1847 bytes --]


在 2021/8/13 下午1:53, Jiri Slaby 写道:
> Hi,
>
> On 12. 08. 21, 14:26, kernel test robot wrote:
>>>> drivers/tty/hvc/hvc_console.c:190:26: warning: variable 'hp' is 
>>>> uninitialized when used here [-Wuninitialized]
>>             spin_unlock_irqrestore(&hp->c_lock, flags);
>>                                     ^~
>>     drivers/tty/hvc/hvc_console.c:149:23: note: initialize the 
>> variable 'hp' to silence this warning
>>             struct hvc_struct *hp;
>>                                  ^
>>                                   = NULL
>
> So you clearly didn't test your change as it would crash quite 
> instantly. I wonder, where do you intend to get hp from in the 
> console::print() hook?
>
> thanks,
According to analysis, this issue may can be solved just by adjust the 
alignment to L1_CACHE_BYTES: 

#define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES)))

Our analysis as below, the original __ALIGNED__ is sizeof(long) which is 
8 for 64bit cpu.
char c[N_OUTBUF] __ALIGNED__; //c[16] __ALIGNED__;

For 4K page, c[16] may cross the page when alignemnt is 8.

In the case the physical address of c[16] is noncontiguous.
|------8----|..........|-----8-----|    PAGE_1
..........................|-----------16----------| c[16]

.........................................|-----8-----|.............|-----8-----| 
PAGE_2
But when the alignment is L1_CACHE_BYTES(eg, 64), or at least 
N_OUTBUF(16), we have no dma issue as c[16] won't cross the page, the 
physical address of c[16] is contiguous.
|--------64--------|.........|--------64---------| PAGE_3

..................................|--c[16]--|

Could you help comments this?  thanks

  parent reply	other threads:[~2021-08-13 16:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12  9:45 [PATCH v6 0/2] make hvc pass dma capable memory to its backend Xianting Tian
2021-08-12  9:45 ` Xianting Tian
2021-08-12  9:45 ` [PATCH v6 1/2] tty: hvc: pass DMA capable memory to put_chars() Xianting Tian
2021-08-12  9:45   ` Xianting Tian
2021-08-12 12:26   ` kernel test robot
2021-08-12 12:26     ` kernel test robot
2021-08-12 12:26     ` kernel test robot
2021-08-12 12:26     ` kernel test robot
2021-08-13  5:53     ` Jiri Slaby
2021-08-13  5:53       ` Jiri Slaby
2021-08-13  5:53       ` Jiri Slaby
2021-08-13  6:04       ` Xianting TIan
2021-08-13  6:04         ` Xianting TIan
2021-08-13  6:04         ` Xianting TIan
2021-08-13 16:07       ` Xianting TIan [this message]
2021-08-13 16:07         ` Xianting TIan
2021-08-13 16:07         ` Xianting TIan
2021-08-13  7:27   ` Greg KH
2021-08-13  7:27     ` Greg KH
2021-08-13  7:27     ` Greg KH
2021-08-13 11:27     ` Xianting TIan
2021-08-13 11:27       ` Xianting TIan
2021-08-12  9:45 ` [PATCH v6 2/2] virtio-console: remove unnecessary kmemdup() Xianting Tian
2021-08-12  9:45   ` Xianting Tian

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=9f6b0b31-b2fd-0706-b40f-d7ffc5c48737@linux.alibaba.com \
    --to=xianting.tian@linux.alibaba.com \
    --cc=amit@kernel.org \
    --cc=arnd@arndb.de \
    --cc=clang-built-linux@googlegroups.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=osandov@fb.com \
    --cc=virtualization@lists.linux-foundation.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 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.