Thursday, February 28, 2008

New form of interrupts - Message Signaled Interrupts

The other day I was looking at the /proc/interrupts file, and I found a line similar to below

494: [ ff] 46 PCI-MSI-edge eth4
495: [ ff] 0 PCI-MSI-edge eth4
496: [ ff] 0 PCI-MSI-edge eth4

First thing off is the presence of 3 interrupts for eth4 device, which is an NVidia NForce card with the forcedeth driver. Also the name "PCI-MSI-edge" is a type I have not head about before. The other was the range of the interrupt number - which was above 255, the max valid interrupt range.

After some googling, I found out that it was the new Message Signaled Interrupts, which were mandated by the PCIe standard. Now instead of a single interrupt, where we have to query the device for the actual event that happened, device drivers can put up an interrupt for each and every event - like in the case above one for rx, one for tx and other for link status etc. This simplifies and cleans up the code. On the hardware side, it makes interrupts in-band, and removes the necessity of a separate pin, reducing the chip's footprint.

Take a look at the <linux kernel src>/Documentation/MSI-HOWTO.txt for more details.

Wednesday, February 27, 2008

Drivers & Hardware

My friend who works in NVidia always complains about how Software drivers have to cover all the mistakes in the hardware. I never faced any issue like that, until today. There was this GBPS network card which gives a pathetic netperf throughput of 780Mbps. After checking a lot of stuff I chanced upon a discussion in netdev about the same driver and how the driver works around a software bug by disabling a very important feature.

I removed the workaround from the kernel, recompiled and installed it on the test machine. I ran netperf and presto! It comes to 989Mbps, as close as possible to the line speed of the interface! As for the hardware bug, it does not get triggered in this particular hardware setup since it requires the PCI-X bus running at 100/133MHz, whereas the test machine's bus is only 66MHz. Problem solved.

Tuesday, February 26, 2008

Same Subnet Interfaces in Linux issue

I always thought that the Linux Networking stack was a fully functional component which is never lacking in features, when compared to other OSs. However a few days ago, I came across a missing piece of functionality - interfaces on the same subnet issue.

You see when you configure 2 interfaces on the same subnet, and try to talk to other machines in the subnet, something unexpected happens. The packets can come in on both interfaces, but can leave only on one of them! This is because of the inherent design of the Linux Forwarding Base, which routes solely based on the destination address, ignoring the source.

Ofcourse its not a deadend in any way. You can still configure a bonding between the 2 interfaces and then assign the 2 ips to the bond virtual interface. But that would be too much trouble, and not exactly a solution for someone seeking resource compartmentalization. Solaris provides a concept called interface grouping for this issue.

Monday, February 25, 2008

Nice Try

Today I was trying to print some variables from the tg3 network driver in the running linux kernel, using GDB on /proc/kcore. Being the lazy type I tried to check kernel variable values though GDB instead of using /proc or /sys interface.

After printing the variables, I started a test to see how it would change. The test went to completion and surprize surprize the value never changed! I did not know what happened and re-ran the test, but no luck. Then I looked through the code and after making sure that the value absolutely has to change, I came to the conclusion that there was something wrong with GDB and restarted it, and presto the new values were visible.

After some googling it turned out that gdb tries to cache the values it retrieves from the core file. The intresting part was that, even though we indicate to GDB that the target is live it still does this. Anyway the solution, from LDD3, is to run "core-file /proc/kcore" everytime we want an updated value.

Sunday, February 24, 2008

Trek to Anantagiri

This Saturday, my roommate and two of my colleagues decided to go to some place. After searching on the net and asking people, it turned out that Anantagiri Hills near Vikarabad, about 76 KM from Hyd might be the ideal destination for the weekend. At last count there were four of us - MJ Pavan my roommate, Ravi Sankar my btech class mate and colleague, Kanishk my colleague and myself.

So on Saturday morning we woke up at 4:15 AM. After dressing up, and packing in a ton of biscuts, cameras, route maps etc. MJ, Ravi and I started for Anantagiri hills at 5:40 on 2 bikes - MJ's Unicorn and my TVS Fiero. On the way we rendezvoused with Kanishk at Nanalnagar near Mehdipatnam. There was a lot of traffic on the way in the city, especially near Mehdipatnam where a flyover is being constructed. After wading through the traffic and then crossed Langer house. Once were were out of the city and near Moinabad, the road turned out to be of excellent condition and have a lot less traffic. This prodded me to floor the accelerator and went for about 40 KM at 90KMPH. About 10 KM from Vikarabad, I stopped as the guys have fallen behind, and then noticed that my bike's engine was leaking engine oil. It was a quite a scare, but anyway the bike appeared to be in running condition, so we continued to Vikarabad. We stopped to get some food in Vikarabad but it was not prepared yet, so we had some tea, asked for directions to Anantagiri and left.

We reached the temple near Anantagiri by 8AM and then parked our bikes in a parking spot. We then went down the stairs near the temple and into the forest. The forest was not very dense. Initially we tried our hand at proving that humans descended from monkeys. Then we came to a place where there was a small elevation in the ground similar to a small hill about 3-4m high. We tried to climb it and took snaps. After this we took a less traveled path into the forest instead of the bigger road-like path. Here had our first experience with some thorny bushes, and after strolling for about 30 mins or so, we came across a green patch of trees. It was a Eucalyptus plantation by some kind soul. There we found many birds like Parrots, finches etc.

Behind this Eucalyptus plantation was a small hillock about 12m high, It was grassy with a few trees on the sides. We decided to climb the hill - little did we know what we were about to face. The slopes were at a 45 degree angle and the soil was very loose with many small pebbles. It was difficult to get a good grip easily. At some places all we could hold on to were blades of dry grass. To crown it all there were many thorny bushes, although my jeans and woodland "tractor" shoes (which we named for its remarkable tread and extraordinary struddiness) saved the day - but not before i got struck by the branch of a thorny bush on my arm.

The view from the top was very beautiful. We took a few pictures and started down on a different side which was less thorny but had more incline. Although this was safer and easier than the uphill route we took, the downward descent made it harder. At one point the branch I was holding to broke and it make me slip a bit although it was not too hard. After that we carefully climbed down and found our way back to the temple.

In the temple they were installing a new idol of Lord Vigneshwara, and MJ helped them a bit. We saw a colorful puja mat there, but on closer inspection it turned out to be a design drawn with colored rice grain. After that we took a group photo and then went to the parking area. It was about 11:10 , when we started to move when Kanishk called me to check his back tyre. It was a biker's worst dream - a flat tyre. After enquiring we found out that the nearest puncture shop was 5km away. Kanishk took my bike and got the repair guy who took the tyre and then repaired it back at his shop and came back and installed it again. MJ, Ravi and myself were meanwhile resting in a small hotel/dhaba. After an hour the entire process was over and we started back. On the way back Kanishk was very pleased to see his bike do 100 KMPH.

MJ, Ravi and myself planned to go to the Ocean park while Kanishk had some work to do in the evening, so he left and we went to the ocean park. But we found all the rides and wave pools filled with children from 4 different schools. We decided against getting down into water and instead rode some non-water based rides like dashing cars, dashing boats etc. We started back at about 4:10 PM from Ocean park and it was about 5:00 PM when we returned home. Ravi then left for the 5:45 MMTS train to his place.

Overall, discounting the tyre puncture and Ocean park rush, it was a very good trip. I think now I know a place to take my friends who visit Hyderabad :). More pictures are available at Picasa





View Larger Map

Wednesday, February 20, 2008

Whitewater Kayaking & Trekking in Mudigere

The planning started with a sudden impulse, which is normal whenever I feel my life slipping away. I mailed my friends about organizing a trip to some beautiful place, and AJ who resides in Bangalore took the initiative. First thing I did was to book tickets to and from Bangalore for the folks from Hyd - Pran, Naresh and myself. After checking a lot of alternatives, we zeroed in on Capture Adventure Tours and they planned a tour for us which would involve White water Kayaking and Trekking near Mudigere in a 2 day tour.

On Friday Evening, Pran, Naresh and myself came in early from office and started to the Kachiguda Rly Station. We hired an auto, and the autowala was a pure nutcase. Anyway we got there on time, and boarded the train. Next day morning at 7:00 the train pulled into Bangalore. We met with AJ who was waiting along with my B.Tech classmate Revanth, Nirmal his roommate and his colleague Shekar. After exchanging pleasantries we started toward Mudigere about 300 KM away. The first 200 KM was normal, but the next 100 was a Ghat section. By the time we came to our destination - Avanthy Estate, It was almost 2PM.


We met Mr Shabbir, the estate manager who informed us that due to a slight change of plans, it would be better to do the Water Kayaking today and the trek tomorrow. We started for Water Kayaking immediatly. After driving a couple of km along the banks of Bhadra, we stopped at a good spot. Vinay our Instructor was already present there, and we helped him unload the kayaks from his jeep to the river bank. After a couple of instructions about Kayaking, we got into the boats. Nirmal and myself were paired into a boat.

Handling a Kayak, like many adventure sports, is an order of magnitude difficult than what it seems like. We were rowing, but being the first time, unable to maintain any sync. This caused the boat to swirl rather than reasonably move forward. Although it was probably a Class 1 route, we were getting stuck in every rock near every rapid possible. Very soon we were slowly learning the tricks. But the initial effort tired us. The later part was more easier. We did this for about 2 hours until 6 PM or so. Then we went back to our rooms. (Whitewater Kayaking Pics)



That night a campfire was arranged and we had a great time drinking beer and shouting boisterously. Naresh and the others took at pulling pran's leg about his "exploits". After some time we retired to our rooms and then fell asleep.

The next day we woke up at around 7 and Shabbir took us on a Van around the estate. After going for 3 KM we were dropped there, and walked back through the coffee plantation. Later we talked with Shabbir about the trek and we realized that there was a miscommunication due to which no real trek was organized for us. So after some discussion, Shabbir agreed to take us to another nearby Estate called JainKhan estate, behind which there were hills.

After spending some time in the JainKhan Estate, we started our trek at 1:30 PM, and we started to climb uphill. After some time Nirmal, who was not feeling very well, and another group who were with us, turned back. We continued our trek to the summit. The view was beautiful, and we took many pictures at the top. After some time we started our trek back, and lost our way. Luckily we found another way and got back through it. (Mudigere Trek Pictures)





After going back to the room, we had a heavy lunch and some beer. Then at night after dinner, we started back to bangalore at 9:30 PM. It was a long ride, and we reached Bangalore by 4:00 AM on monday morning. After sleeping for a couple of hours, Nirmal and Revanth left for office, whereas the rest of us just lazed around and in the evening we started back to Hyderabad.