This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 05/10] Invalidate or shrink dcache when setting is changed.


On 11/19/2013 06:00 AM, Yao Qi wrote:
> On 11/18/2013 11:56 PM, Pedro Alves wrote:
>> On 11/03/2013 05:54 AM, Yao Qi wrote:
>>> Nowadays, when cache size or line size is changed by command,
>>> 'target_dcache' is invalidated.  It is too conservative.  We can
>>> optimize in the following ways,
>>>
>>>   - Don't have to invalidate dcache immediately after cache size or
>>>     line size is changed.  We can postpone the invalidation to the moment
>>>     using 'target_dcache'.
>>>   - Don't have to invalidate dcache if the cache size is changed.  If
>>>     cache size is changed to the value which is still greater than
>>>     dcache's size, nothing should be done.  If change to the value
>>>     which is less than dcache's size, just evict cache lines.
>>>
>>> This is what this patch does.
>>
>> Actually, my "My thoughts exactly." comment in the other patch was
>> originally directed at this patch.  Do we really need this extra
>> complication?  What's the use case that needs this?
>>
> 
> Here are three use cases,
> 
>   1) target dcache has 16 cache lines, and dcache size is 4096.  User 
> types command "set dcache size 32" or "set dcache size 4160".
>   2) target dcache has 16 cache lines.  User types command "set dcache 
> size 8".
>   3) line size of target dcache is 32.  User types commands
> 
>      "set dcache line-size 16"  // change line-size to 16.
>      // change it back.
>      "set dcache line-size 32"

Sure, OK, I guess I did the wrong question then.  I really mean,
why should we care about preserving the cache when the user
changes cache size?  What makes this a use case users actually
care about?  I don't think users going to be doing this
sort of thing in a loop?  At most a couple times to check which
size might be better for then, and then stick it in .gdbinit,
forever after forgotten.

Actually, if I was probing for the ideal size, I think I'd be
annoyed that GDB didn't flush the cache, as I'd try
disassembling/backtracing with different cache sizes, and
always want to start from a cold cache.

> This "extra complication" looks natural or reasonable to a software 
> cache.  

It's always a complication/necessity/usefulness balance.
It doesn't look so reasonable if the complication it adds
isn't useful in practice, because more code usually means more
chances of getting things wrong.  The question is then what is
the real use case that makes this necessary, as opposed to keeping
it simple.

> We are using cache, and we'd like to do as few invalidations as 
> possible.

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]