On Tue, Jan 17, 2017 at 08:12:20AM +0100, Peter Zijlstra wrote: > On Tue, Jan 17, 2017 at 11:05:42AM +0900, Byungchul Park wrote: > > On Mon, Jan 16, 2017 at 04:10:01PM +0100, Peter Zijlstra wrote: > > > On Fri, Dec 09, 2016 at 02:12:03PM +0900, Byungchul Park wrote: > > > > > + > > > > + /* > > > > + * Whenever irq happens, these are updated so that we can > > > > + * distinguish each irq context uniquely. > > > > + */ > > > > + unsigned int hardirq_id; > > > > + unsigned int softirq_id; > > > > > > An alternative approach would be to 'unwind' or discard all historical > > > events from a nested context once we exit it. > > > > That's one of what I considered. However, it would make code complex to > > detect if pend_lock ring buffer was wrapped. > > I'm not sure I see the need for detecting that... > > > > > > > After all, all we care about is the history of the release context, once > > > the context is gone, we don't care. > > > > We must care it and decide if the next plock in the ring buffer might be > > valid one or not. > > So I was thinking this was an overwriting ring buffer; something like > so: OK. I am making code just overwrite ring buffer when overflowing it, instead of warning the situation. Thank you very much. > > struct pend_lock plocks[64]; > unsigned int plocks_idx; > > static void plocks_add(..) > { > unsigned int idx = (plocks_idx++) % 64; > > plocks[idx] = ...; > } > > static void plocks_close_context(int ctx) > { > for (i = 0; i < 64; i++) { > int idx = (plocks_idx - 1) % 64; > if (plocks[idx].ctx != ctx) > break; > > plocks_idx--; > } > } > > Similarly for the release, it need only look at 64 entries and terminate > early if the generation number is too old. > > static void plocks_release(unsigned int gen) > { > for (i = 0; i < 64; i++) { > int idx = (plocks_idx - 1 - i) % 64; > if ((int)(plocks[idx].gen_id - gen) < 0) > break; > > /* do release muck */ > } > } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>