<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technicalities &#187; development</title>
	<atom:link href="http://www.sirena.org.uk/log/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sirena.org.uk/log</link>
	<description>Just another random blog</description>
	<lastBuildDate>Sat, 21 Jan 2012 23:41:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Making patches easy to review</title>
		<link>http://www.sirena.org.uk/log/2011/09/09/making-patches-easy-to-review/</link>
		<comments>http://www.sirena.org.uk/log/2011/09/09/making-patches-easy-to-review/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 10:44:33 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[ASoC]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Planet Debian]]></category>
		<category><![CDATA[regmap]]></category>
		<category><![CDATA[regulator]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[code review]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[gerrit]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://www.sirena.org.uk/log/?p=416</guid>
		<description><![CDATA[One of the big things that seems to cause a learning curve for many new contributors for Linux and other projects that make a big effort with code review is the process of putting patches together in a way that makes the code review process more smoothly. This is a fairly straightforward thing but it [...]]]></description>
			<content:encoded><![CDATA[<p>One of the big things that seems to cause a learning curve for many new contributors for Linux and other projects that make a big effort with code review is the process of putting patches together in a way that makes the code review process more smoothly. This is a fairly straightforward thing but it takes a bit of getting used to for people who aren&#8217;t used to the idea of patches and commits as a means of communication rather than just a mechanical thing you do to get changes into the codebase. In cases I&#8217;ve seen the difficulty . I&#8217;m mostly going to talk about this in the Linux context where patches are reviewed by e-mail but the same ideas apply if you&#8217;re using a tool like <a href="http://code.google.com/p/gerrit/">gerrit</a> to do the reviews; it&#8217;s also mostly focused on detailed review rather than design level review.</p>
<p>The basic idea is fairly simple &#8211; the goal is to make it as easy as possible for someone to read and understand the change that&#8217;s being made.</p>
<ul>
<li>Make sure the code matches the coding style of the code being modified.</li>
<li>Make patches as small and self contained as possible &#8211; having many patches is much easier than having complicated patches.</li>
<li>Provide a changelog clearly describing everything that&#8217;s going on in the patch.</li>
</ul>
<p>The result here should be something that&#8217;s easy for people to review. Keeping in line with the coding style is just a generally good idea for code legibility which is obviously a key thing for people reading the code to review it. Having a clear description of the change means that the reviewer knows what the patch is supposed to do and can verify that the patch does that rather than having to spend effort figuring out if whatever the code is doing is intentional. Making changes small and simple makes them much easier to think about &#8211; the idea itself is easier to keep in your head and there&#8217;s fewer things to check so the process of validating things is easier.</p>
<p>It&#8217;s not just about making life easier for reviewers. The process of making simple changes and describing them clearly can be really helpful for spotting issues when writing code; it forces you to think through what&#8217;s being done much more clearly than might happen otherwise. There&#8217;s also an ongoing benefit to anyone working with the code in the future. Since each change ends up including at least some explanation of what the code is supposed to do and since revision control systems generally have some equivalent of <a href="http://www.kernel.org/pub/software/scm/git/docs/git-annotate.html">git annotate</a> it&#8217;s usually reasonably straightforward to find the changes that introduced the code that you&#8217;re looking at. Small changes with good changelog entries mean it&#8217;s much more likely that the changelog will provide a useful explanation as to what the author was thinking and explain why the code is the way that it is. It&#8217;s much harder for documentation to go missing from the SCM than it is for it to go missing elsewhere, and it&#8217;s much more likely that documentation in the commit is going to be up to date than external documentation, especially prewritten design documentation.</p>
<p>In the context of large scale reviews the usual technique is to combine reviews of individual changes with a read through of the final code after all the individual changes have been applied. Often the build up of the code through incremental changes is a enough to show the overall design but a read through of the final code can be helpful in allowing people to understand where things are going.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sirena.org.uk/log/2011/09/09/making-patches-easy-to-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing core code</title>
		<link>http://www.sirena.org.uk/log/2011/03/13/changing-core-code/</link>
		<comments>http://www.sirena.org.uk/log/2011/03/13/changing-core-code/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 21:12:10 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Planet Debian]]></category>
		<category><![CDATA[culture]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://www.sirena.org.uk/log/?p=383</guid>
		<description><![CDATA[One of the biggest differences between working on most other OSs and working upstream on drivers for the Linux kernel is that elsewhere the core is usually a fixed thing that has been released and can&#8217;t really be changed, even if source is available (which may not even be the case). If whatever subsystem you&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>One of the biggest differences between working on most other OSs and working upstream on drivers for the Linux kernel is that elsewhere the core is usually a fixed thing that has been released and can&#8217;t really be changed, even if source is available (which may not even be the case). If whatever subsystem you&#8217;re working in can&#8217;t cope with the thing you&#8217;re trying to express then one of the things it&#8217;s really useful to be good at is working out ways to implement the behaviour that&#8217;s required behind the back of the subsystem. It&#8217;s very common to see such code in drivers submitted by hardware vendors, particularly those that are new to Linux, as this is such a big mindset shift.</p>
<p>With kernel development the approach is much more to make sure that the core can cope with whatever needs expressing. It&#8217;s not always done in the core &#8211; for example, sometimes the issue is due to unusually limited hardware and very likely to never come up again &#8211; but it&#8217;s very unusual to see code merged that doesn&#8217;t at least fit in with the design of the subsystem.</p>
<p>This post is inspired by <a href="https://lkml.org/lkml/2011/3/11/324">a brief exchange with Thomas Gleixner on linux-kernel</a> who articulated the advantages of doing things this way very well:</p>
<blockquote>
<pre> - It's usually simpler and faster as the core code has all the
   necessary information. So that's even an argument which managers
   might understand.

 - Such workarounds, when not caught, tend to spread themself
   magically because driver writers checkout the existing code of
   similar devices and copy/paste/modify^Wuglify them over and over.

 - In the worst case such workarounds make the core maintainence
   harder and in some cases impossible, because they silently imply
   semantics on the core w/o the core maintainer knowing about them.</pre>
</blockquote>
<p>The last point is the most important one to me as a subsystem maintainer &#8211; I really don&#8217;t want to be merging code that is going to create issues with ongoing development of the subsystem. This is all another facet of the <a href="http://lxr.linux.no/linux/Documentation/stable_api_nonsense.txt">policy on stable APIs</a>: APIs are only worth working around if they&#8217;re fixed, and the assumptions that end up embedded in a workaroud are as much part of the API as the explicit interfaces.</p>
<p>It&#8217;s things like this that make Linux such a pleasure to work on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sirena.org.uk/log/2011/03/13/changing-core-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tracing ASoC with trace events</title>
		<link>http://www.sirena.org.uk/log/2011/01/22/tracing-asoc-with-trace-points/</link>
		<comments>http://www.sirena.org.uk/log/2011/01/22/tracing-asoc-with-trace-points/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 16:21:50 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[ASoC]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Planet Debian]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[alsa]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[trace]]></category>

		<guid isPermaLink="false">http://www.sirena.org.uk/log/?p=330</guid>
		<description><![CDATA[Kernel 2.6.38 will add support for tracing ASoC using trace points. Previously all logging for ASoC had been done using printk(), meaning that changing the active logging required a kernel rebuild and that when trace was enabled the volume of trace could easily become very disruptive to other logging within the system. Trace points solve these [...]]]></description>
			<content:encoded><![CDATA[<p>Kernel 2.6.38 will add support for tracing ASoC using <a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/trace/tracepoints.txt;h=c0e1ceed75a441b692bf447b3fcdc49d8abdd1cc;hb=refs/heads/master">trace points</a>. Previously all logging for ASoC had been done using printk(), meaning that changing the active logging required a kernel rebuild and that when trace was enabled the volume of trace could easily become very disruptive to other logging within the system. Trace points solve these problems by providing a framework for enabling and disabling individual traces dynamically and separate logging infrastructure designed for easy filtering and post-processing. When using trace points it&#8217;s reasonable to leave them enabled all the time, making life much easier especially when debugging intermittent problems.</p>
<p>There&#8217;s a bunch of existing documentation out there for the trace subsystem, including some in the kernel under <a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=tree;f=Documentation/trace;hb=refs/heads/master">Documentation/trace</a>, which I won&#8217;t repeat here. The ASoC events are grouped together under &#8216;asoc&#8217;. The raw log can be viewed by looking at the file tracing/trace in debugfs. Here&#8217;s a sample output from starting playback of an MP3 on a Samsung SMDK6410 reference system using WM8580, a high performance six channel CODEC with a very simple software interface:</p>
<pre>mplayer-1673  [000]   183.920000: snd_soc_dapm_start: card=SMDK-I2S
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=Rear val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=Center+Sub val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=Front val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=VOUT3R val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=VOUT3L val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=VOUT2R val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=VOUT2L val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=VOUT1R val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=VOUT1L val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=DAC3 val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=DAC2 val=1
mplayer-1673  [000]   183.920000: snd_soc_dapm_widget_power: widget=DAC1 val=1
mplayer-1673  [000]   183.920000: snd_soc_bias_level_start: card=SMDK-I2S val=2
mplayer-1673  [000]   183.920000: snd_soc_bias_level_done: card=SMDK-I2S val=2
mplayer-1673  [000]   183.920000: snd_soc_reg_read: codec=wm8580-codec.0-001b.27 reg=32 val=1e
mplayer-1673  [000]   183.920000: snd_soc_reg_write: codec=wm8580-codec.0-001b.27 reg=32 val=2
mplayer-1673  [000]   183.920000: snd_soc_bias_level_start: card=SMDK-I2S val=3
mplayer-1673  [000]   183.920000: snd_soc_bias_level_done: card=SMDK-I2S val=3
mplayer-1673  [000]   183.920000: snd_soc_dapm_done: card=SMDK-I2S
mplayer-1673  [000]   183.920000: snd_soc_reg_read: codec=wm8580-codec.0-001b.27 reg=13 val=10
mplayer-1673  [000]   183.920000: snd_soc_reg_write: codec=wm8580-codec.0-001b.27 reg=13 val=0</pre>
<p>Each line represents a trace event, showing the process that initiated the event, the CPU it ran on and the time it was recorded at together with event-specific details. On this system the time is reported with 10ms accuracy and the CODEC is very simple so the timing information is not terribly informative, but more accurate timers can be really helpful in analysing what&#8217;s going on with more complex CODECs. The set of events available will change over time, the key ones currently present in the kernel are:</p>
<ul>
<li>snd_soc_dapm_start and snd_soc_dapm_done: These events show the start and stop of the DAPM algorithms, showing the time spent on power management decisions.</li>
<li>snd_soc_dapm_widget_power events are generated for each of the widgets which DAPM has determined needs to change state. The &#8216;val=1&#8242; means that all these widgets are being powered up, val=0 would show power down.</li>
<li>snd_soc_reg_write events show values written to registers.</li>
<li>snd_soc_reg_read events show values read from registers &#8211; these reads may be done from the register cache, or may be from the hardware.</li>
<li>snd_soc_dapm_widget_event_start and snd_soc_dapm_widget_event_done show the time spent in per-widget event callbacks.</li>
</ul>
<p>The set of events traced will change as the subsystem develops and as people gain more experience with using the trace API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sirena.org.uk/log/2011/01/22/tracing-asoc-with-trace-points/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chasing patches into Linux</title>
		<link>http://www.sirena.org.uk/log/2009/09/05/chasing-patches-into-linux/</link>
		<comments>http://www.sirena.org.uk/log/2009/09/05/chasing-patches-into-linux/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 17:58:11 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Planet Debian]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[social]]></category>

		<guid isPermaLink="false">http://www.sirena.org.uk/log/?p=60</guid>
		<description><![CDATA[One thing that often seems to cause problems for people who work over many different areas of the Linux kernel is the process of making sure that patches actually get reviewed and applied. Where the relevant subsystem is actively maintained it&#8217;s not a problem but that&#8217;s not always the case. Sometimes maintainers are busy or [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that often seems to cause problems for people who work over many different areas of the Linux kernel is the process of making sure that patches actually get reviewed and applied. Where the relevant subsystem is actively maintained it&#8217;s not a problem but that&#8217;s not always the case. Sometimes maintainers are busy or on holiday and miss things, sometimes there are other problems. In these cases the onus is on the patch submitter to spot the problem and make sure that something is done to ensure that the patch doesn&#8217;t get forgotten.</p>
<p>There&#8217;s a few  workflows for dealing with this. My preferred one is to track the appearance of my patches in Stephen Rothwell&#8217;s <a href="http://git.kernel.org/?p=linux/kernel/git/eranian/linux-next.git;a=summary">linux-next</a> tree, which tracks individual development trees destined for merge into Linus&#8217; tree. I create a git branch based on the current state of this tree then apply the patches I&#8217;m submitting on top of that. This lets me spot any potential merge conflicts that they&#8217;ll create but the main function is to allow me to come back to the branch later and track which of the patches has shown up in one of the trees that Stephen tracks. To do this I rebase the branch onto the current state of linux-next:</p>
<blockquote>
<pre>git rebase --onto next/master old-master</pre>
</blockquote>
<p>where &#8216;old-master&#8217; is the last linux-next commit in the branch. This will flag up any merge issues that have come up due to changes in other trees and will also handle patches that are already present in one of the trees in -next by dropping my local version. The end result is a branch based on the new linux-next with all the patches that were not yet applied in it. I can see what still needs to be looked at by examining the log</p>
<blockquote>
<pre>git shortlog next/master..</pre>
</blockquote>
<p>and take any appropriate action, such as following up with the relevant maintainer or trying to find out what&#8217;s going on with the subsytem if it looks like the subsystem maintainers are inactive.</p>
<p>One possible problem with this approach is that a patch may be applied and then subsequently dropped &#8211; this is rare but it can happen. I deal with that by also keeping a normal unrebased development branch whch has the changes in Linus&#8217; tree merged  into it periodically and incremental patches for any review updates that occur during the submission process. By looking at the diff between that and other trees I can see any changes that have got lost along the way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sirena.org.uk/log/2009/09/05/chasing-patches-into-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

