linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Mark Mason <mason@postdiluvian.org>,
	linux-ide@vger.kernel.org, jgarzik@pobox.com,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Jens Axboe <jens.axboe@oracle.com>
Subject: Re: libata/sata_sil24 cache alignment problem?
Date: Thu, 14 Feb 2008 12:05:00 +0900	[thread overview]
Message-ID: <47B3AFDC.5040605@gmail.com> (raw)
In-Reply-To: <20080214002135.065dd322@core>

Alan Cox wrote:
>> I hadn't considered that approach due to the way the ata_port is allocated:
>>
>>> libata-core.c:
>>>         host = scsi_host_alloc(ent->sht, sizeof(struct ata_port));
>>>
>>> hosts.c:
>>> struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
>>> {
>>>         shost = kzalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask);
>>> }
>> The ata_port allocation is tacked onto the end of the Scsi_Host
>> allocation, so the start of ata_port will only be cache aligned if the
>> end of the Scsi_Host struct is, although that would be easy enough to
>> fix since it's currently aligned to an unsigned long boundary.
> 
> You are right.

For recent kernels, ata_port is allocated separately so
____cacheline_aligned should be enough.

>> I like that approach better, since it's clearer what the intent is,

But, yeah, allocating separately is probably safer.

>> and it's easier.  Is there any other way that the ata_port struct
>> might be used that would invalidate this?  
> 
> I can't think of one. The object lifetime is right - the ata_port is
> created before the port buffer is used and destroyed after it is finished
> (obviously or embedding it in the struct wouldn't work either)

I'll prep a patch for the current kernel.  Hmmm... This means that any
DMA buffer should be aligned to cacheline.  Block layer DMA alignment
helpers should probably take this into consideration and we better add
warnings to dma map functions.  This only affects DMA-to-memory, right?

Thanks.

-- 
tejun

  reply	other threads:[~2008-02-14  3:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-12 18:02 libata/sata_sil24 cache alignment problem? Mark Mason
2008-02-12 22:12 ` Alan Cox
2008-02-12 23:36   ` James Bottomley
2008-02-13  2:13     ` Alan Cox
2008-02-13  2:32       ` James Bottomley
2008-02-13 18:47   ` Mark Mason
2008-02-13 20:21     ` Alan Cox
2008-02-13 21:25       ` Mark Mason
2008-02-14  0:21         ` Alan Cox
2008-02-14  3:05           ` Tejun Heo [this message]
2008-02-14  9:44             ` [PATCH] libata: align ap->sector_buf to cacheline Tejun Heo
2008-02-14  9:48             ` [PATCH] scsi: align shost->hostdata " Tejun Heo
2008-02-14 15:05               ` James Bottomley
2008-02-14 22:49                 ` Tejun Heo
2008-02-15 18:57                   ` James Bottomley
2008-02-21  2:32                     ` Tejun Heo
2008-02-13 18:51   ` libata/sata_sil24 cache alignment problem? Mark Mason
2008-02-12 23:25 ` Thomas Evans

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=47B3AFDC.5040605@gmail.com \
    --to=htejun@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=jens.axboe@oracle.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=mason@postdiluvian.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).