jack: (Default)
[personal profile] jack
OK, so. We want to allocate a large block of memory that is contiguous as physical memory. That means allocating physical memory in the kernel (as with kmalloc), and then later providing it to userspace software. Presumably then mapping it into virtual memory for use in userspace with mmap from physical memory in dev/mem, although we may be doing something different for reasons which aren't relevant here.

We happen to have a kernel driver already for other experiments with our specific hardware, so we have somewhere convenient to put this kernel code as needed.

This is running on a hardware board dedicated to a single task, so we have a few advantages. We would prefer to allocate a large chunk on start-up, and will have complete control over which programs we expect to use it, we don't need to dynamically manage unknown different drivers trying to get this memory, and we never intend to free it, and the board will only be used for this so we don't need to make sure other programs run ok. And there's no restriction on addresses, DMA and other relevant peripherals can access the entire memory map, so unlike x86 we don't need to specifically reserve *low* memory.

There are several different related approaches, and I went through a few rabbit holes figuring out what worked.

Option 1: __memblock_alloc_base()

From research and helpful friends, I found some relevant instructions online. One was from "Linux Device Drivers, 3rd edition", the section entitled "Obtaining Large Buffers", about using alloc_bootmem_low to grab kernel pages during boot. I'm not sure, but I think, this was correct, but the kernel started using memblock instead of bootmem as a start-up allocator?

From the code in the contiguous memory allocator (search the kernel source for "cma"), I learned that possibly I should be using memblock functions as well. I didn't understand the different options, but I used the same one as in the contiguous memory allocator code, __memblock_alloc_base and it seemed to work. I tried large powers of 2 and could allocate half of physical memory in one go. I haven't fully tested this, but it seemed to work.

There are several related functions, and I don't know for sure what is correct, except that what the cma code did worked.

This code is currently in a kernel driver init function. The driver must be compiled statically into the kernel, you can't load it as a module later. You could put the code in architecture specific boot-up code instead.

Option 2: cma=

fanf found a link to some kernel patches which tried to make a systematic way of doing this, based on some early inconsistently-maintained patch, which later turned into code which was taken up by the kernel. Google for "contiguous memory allocator". There's an article about it from the time and some comments on the kernel commit.

It's a driver which can be configured to grab a large swath of contiguous memory at startup, and then hand that out to any other driver which needs it.

You specify the memory with "cma=64MB" or whatever size on the kernel command line. (Or possibly in the .config file via "make menuconf"?) You need to do this because it allocates on start-up, and it doesn't know if it should have this or not.

It then returns this memory to normal calls to "alloc_dma_coherent" which is designed to allocate memory which is physically contiguous, but doesn't normally allocate such big blocks. I hadn't tested this approach because I didn't need any specific part of memory so I'd been looking at kmalloc not "alloc_dma_coherent", but a colleague working on a related problem said it worked on their kernel.

It may also do clever things involving exposing the memory to normal allocating, but paging whatever else is there out to disk to free it up when needed, I'm not sure (?)

I was looking at the source code for this and borrowed the technique to allocate memory just for our driver. We may either go with that (since we don't need any further dynamic allocation, one chunk of memory is fine), or revert to using the cma later since it's already in the kernel.

I went down a blind alley because it looked like it wasn't enabled on my architecture. But I think that was because I screwed up "make menuconfig" not specifying the architecture, and actually it is. Look for instructions on cross-compiling it if you don't already have that incorporated in your build process.

Option 3: CONFIG_FORCE_MAX_ZONEORDER

This kernel parameter in .config apparently increases the amount of memory you can allocate with kmalloc (or dma_alloc_coherent?). We haven't explored this further because the other option seemed to work, and I had some difficulties with building .config, so I don't know quite how it works.

I found the name hard to remember at first. For the record, it means, ensure the largest size of zone which can be allocated is at least this order of magnitude (as a power of two). I believe it is actually 1 higher than the largest allowed value, double check the documentation if you're not sure.

Further options

There are several further approaches that are not really appropriate here, but may be useful under related circumstances.

* On many architectures, dma does scatter-gather specifically to read or write from non-contiguous memory so you shouldn't need this in the first place.

* Ensure the hardware can write to several non-contiguous addresses.

* Allocate the several blocks of the largest size kmalloc can allocate, and check that they do in fact turn out to be contiguous since kernel boot-up probably hasn't fragmented the majority of memory.

* Ditto, but just allocate one or several large blocks of virtual memory with malloc, and check that most of it turns out to be allocated from contiguous physical memory because that's what was available. This is a weird approach, but if you have to do it in userspace entirely, it's the only option you could take.

[TV] IN WHICH I HAVE FEELINGS.

Jul. 27th, 2017 06:16 pm
kaberett: Clyde the tortoise from Elementary, crawling across a map, with a red tape cross on his back. (elementary-emergency-clyde)
[personal profile] kaberett
Feelings the first: I've just had A finish Season 1 of Korra, and I'm going to be making him watch Spirited Away before Season 2, because that sequence is frankly one of the few things I like about Season 2, so. BUT. Having very recently watched the end of Book 3 of A:tLA with him, I Noticed a Thing about the end of Season 1 that I had not, previously, and then FEELINGS. Spoilers, obviously. )



Orphan Black is also a bunch of FEELINGS, also has spoilers (up to 5.07), and also comes with a content note for Significant Gore slightly beyond what one normally expects of the show, along with all the usual "everything is horrifying but I love all of them" caveats.

Read more... )

Logic Cassandra

Jul. 26th, 2017 10:24 am
jack: (Default)
[personal profile] jack
Logic Cassandra: No, don't bring the horse into the city! It has soldiers inside.
Trojans: Pshaw.
Logic Cassandra: Wait, I mean, sit on your hands all night, and nothing much will happen. No gods will give you a big pile of gold.
Trojans: Hah, no way you're putting one over on us. We'll sit here and take the gold, thanks.
Logic Cassandra: In fact, you're going to go on disbelieving everything I say.
Logic Cassandra: *level stare*
kaberett: Clyde the tortoise from Elementary, crawling across a map, with a red tape cross on his back. (elementary-emergency-clyde)
[personal profile] kaberett
I have been meaning to write this up for a while and have just had cause to do so elsenet; ergo, have a copy of Alex's Algorithm For Choosing A New GP. It has served me pretty well thus far.

Comments and additions welcome, as ever. :-)

Read more... )

Hugos: Remaining finalists

Jul. 20th, 2017 12:30 pm
jack: (Default)
[personal profile] jack
I voted in several more categories, but eg in long form dramatic presentation, I didn't have a lot to say so I'm not going to try to recap it here.

Novellas

Ballard of Black Tom was a very moving Lovecraft inspired story, from the perspective of a black new yorker, it paints a great portrait of his day to day life in 1920s (?) NY, and his initially minor dealings in mythos stuff. It was quite creepy once it started, but I've still to read the more lovecraftian ending of the story.

The Dream-Quest of Vellitt Boe was *also* a very good Lovecraft inspired story, set in the dreamlands, and the travels of a professor at the newest university college, the women's only college, through strange parts of dream, weird gods, and eventually maybe the waking world.

Penric and the Shaman is enjoyable in all the ways you'd expect it to be if you've read other Chalion stories by Bujold. It says a little about shaman/demon interactions which was only incidentally touched on before, and has slightly more of a role for a Father-worshipping figure. But it doesn't add a lot new.

A Taste of Honey, I still need to read, but the cover is *gorgeous* and there's some good male/male flirting on the first page. I'm not sure how that's going to turn out.

This Census-Taker. Interesting worldbuilding, I'm not sure where it's going, I still need to finish it.

Best Novelette

“The Art of Space Travel” about a small cast of characters living and working near Heathrow, against a backdrop of a second Mars colony mission, 30 years after the first tragic failed attempt. I loved the character stuff, and background matter-of-fact look at a possible mars mission, although I wished they'd tied together more closely: I wanted to know more about the disaster, and the next mission. The title refers to the name of a textbook.

“The Tomato Thief” by Ursula Vernon. All of her stories are pretty good, although I didn't love this as much as some of her others, despite being pretty good.

“Touring with the Alien”, an odd-job woman ends up with the role of taking reclusive alien visitors on a road trip to see some of earth. Interesting musings on free will etc even though I wasn't convinced where they ended up. Again, I loved the day-to-day interaction of the protagonist and the other characters.

“The Jewel and Her Lapidary”, interesting worldbuilding, but I need to see how this finishes up. Jewels were nobility of a hidden kingdom, who kept it secret safe and stable with various supernatural powers granted to them by gems, but could only be bestowed by Lapidary servants.

You’ll Surely Drown Here If You Stay” by Alyssa Wong. Something about a desert? It looked good but I couldn't get into it at all (sorry).

Thoughts on the term "Secondary"

Jul. 19th, 2017 09:25 pm
jack: (Default)
[personal profile] jack
I've had several conversations about why "secondary" is such a loaded concept in poly relationships and feel like I'm slowly getting how people feel. But still, I feel there's a lot that's important to people I'm missing.

1. Not enough

It seems like many people are starting from the assumption that nobody *wants* to be a secondary, and the concept is basically synonymous with "I'll probably want more but I'll settle for what I can get". And yes, if that's how you feel, then that might be ok, but there is an inherent source of tension which is likely

I never had that assumption, only as I've met a wider variety of relationships have I started to understand it. It seemed to me, some people had many parallel relationships (either a small number of permanent partners who are equal priorities in organising your life whether or not they're different in other ways, or varied relationships each negotiated individually etc). Or they had one or two main partners, and other partners as well, usually people who themselves had many other partners, or had other major commitments, or otherwise were at a point in their life where a relationship *might* become much more, but they weren't looking for more, they were looking for something which fit their life right now, even if they had limited time and energy.

But if every relationship is "I fall deeply in love" then it makes sense that anything other than deep and permanent is really hard. Likewise, if you only have room for one relationship, it's a very painful choice to be with someone who wants to be with someone else more, if that's not what you want, and either "they need to have room for their relationship with you to grow" or "they need to realise that they may not be kind by having a relationship with you" may be issues.

With the benefit of hindsight, that looks to me like, "here's a form of relationship that suits some people but not others, don't choose it if it doesn't suit you". But if you have no experience of possible relationships, and the only model you have is "A and B are the love of each other's lives, and C is there too but is treated with absolutely zero respect", it's easy to fall into that model, and come out feeling like it should be burned to the ground.

2. Negotiating from a position of weakness

The other thing I had to say is, it's common for a relationship (not romantic, any form of association) to involve people with different amounts of power. Sometimes that's seriously unfair, as in a bad boss and an employee who needs the job: the boss has every opportunity to take advantage, to not just be unfair but to manipulate the interactions to their advantage by changing the rules all the time.

Sometimes it's completely fair, as in A wants to date B and B doesn't want to date A: then B deservedly has completely control over who they want to date, and they may reject A politely and compassionately (if A is not a jerk) or harshly (if A is a jerk, or if B is for that matter).

"Fair" doesn't mean "half and half". Although in most healthy ongoing relationships, jobs, romance, etc, both sides get comparable good things out of it.

A relationship can be unequal. Say, A has young children, another partner, and many other commitments. And they have a fortnightly date with B, whose commitments are a lot more flexible. That's just how their lives are, no-one is deliberately being unfair. But it does turn out, B has more flexibility than A, so they end up rearranging things more often.

Now here's the distinction. At the moment A doesn't really have the power to offer a lot more time to B. But they do have the power to make arrangements respectfully, by being clear in advance what commitments they can and can't make. By being honest about what time they have. By being upfront that occasionally emergencies will happen but that won't be a default. By not changing plans at short notice and expecting B to cope, can we emphasise that one.

Maybe B *could* cope with that if they had to, but if A forces them to for no reason, or for unfair reasons like, "My other partner is jealous if I spend ANY TIME WITH YOU AT ALL so rather than talking about it I'm just going to constantly jerk you around in the hope that eventually they're happy", then A is not treating B at all respectfully.

The reason I mention this particularly is that it seemed to be a common complaint from people familiar with certain sorts of history, that A had apparently logical reasons why they needed to constantly change stuff around. But it's possible for A to be unfront about what's not really changeable, while also being respectful and communicative about everything.

This is obvious in some relationships: most people with friends know that sometimes a friends' job or partner need them right now, and most friendships, if you move away your friend will usually stay with their job or family, not move with you. And that's just normal: almost all humans have many relationships and give different things to different ones. But it's also normal that friends are not jerks about it, and (a) don't constantly talk about how something else in their life is more important than you and (b) make time for you sometimes and don't just cancel all the time without telling you.

Postscript

Hopefully this is obvious, but this is, me trying to understand many thoughts I've heard from different places, and not about any particular relationships of anyone (especially not anyone I know). Hopefully that postscript isn't needed, but I know it's possible for me to post "thoughts on X" and people to worry "is this about me".

an amusing confluence

Jul. 19th, 2017 11:03 am
kaberett: Overlaid Mars & Venus symbols, with Swiss Army knife tools at other positions around the central circle. (Default)
[personal profile] kaberett
1. Mr Men In London (press release); official merch; Londonist.

2. The Tube is dropping "ladies and gentlemen" as a passenger greeting.


Ergo: 3. Who do I gotta hassle to make e.g. "Mx Cool" and "Little Mx Stubborn" etc happen?

Inbox Nonzero

Jul. 18th, 2017 10:38 pm
jack: (Default)
[personal profile] jack
Quite a long time ago now, I read about the concept of inbox zero. For a long time I struggled with various productivity techniques. I sometimes temporarily achieved inbox zero, and I made big inroads against the habit of having all the urgent emails muddled in with everything else I'd ever received. Although that never quite became permanent.

However, now there maybe has been a permanent sort of shift. I think a combination of receiving less urgent emails, and of having a regular non-email based per-week todo list, and of generally being less stressed by all urgent things, have led to a point where I no longer *need* inbox zero. I generally only have a few emails needing attention, and those are starred. And other recent-ish email sits around in my inbox to a certain extent not doing much harm, but being handy if I need it.

And I'm sufficiently non-stressed that it's not usually something I need to *set aside time for*, but something I can do when I'm checking my email anyway. Any longer time commitments get put in a separate todo.

Non-email email (social network notifications, mailing lists, confirmations, etc, etc) gmail helpfully puts into a separate tab. Social network stuff I star anything I want to reply to, and empty it out every so often. Everything else I just glance at, and if it needs any response move to my main inbox and star it.

This has bad effects as well. Because it *usually* just works, if I get an urgent email and then suddenly go away, it can fall through the cracks. But that's hopefully ok, it's mostly how most people deal with tasks: they usually do it fine but occasionally miss something, instead of needing to be always perfect else they fail forever.
jack: (Default)
[personal profile] jack
Every Heart a Doorway tells the story of a school for the recovery of children who've been subject to portal fantasy stuff, specifically people wanted to stay but were cast out for some reason. It's pretty good; I felt it could have embraced the premise *better*, but it still did a pretty good job.

I have lots of different thoughts about this.

Returning from portal fantasy

One of the biggest is probably that, it's written as if people being cast out is a central feature of secondary worlds, whereas originally I think it's more like, the authors didn't think about it much either way, they just tacked on a happy ending even if it didn't really make sense in the book.

But as liv points out, many people found portal fantasies incredibly moving as children because they wanted to escape somewhere else from where they were, and returning was horrible, and this story serves very very well as an emphatic rejection of that trope.

Funnily enough that was never me. Lots of my friends overcame a lot of childhood problems, but though I was nerdy and bad at making friends, my parents were great, and I never wanted to get away from here, even if I was drawn to the idea of going somewhere where my strengths could blossom. I got some of that by going into maths and programming.

Flaws

I enjoyed this more than most of the other Seanan Mcguire I've read, even the Mira Grant. I think the strengths were similar, but the bits where "the characters go where the plot says, completely disregarding logic, common sense, emotion, characterisation, survival, or physical possibility" were much less prominent.

At least to me -- I know some people didn't find that a problem in any of her books, and some people were bothered by it in this one. But there are going to be *some* rants in the spoiler section.

I wasn't bothered by some things that bothered other people. To me, the variety of sexualities etc didn't feel shoehorned in, except occasionally (and I was pleased it was there). I wasn't bothered by shifts in narration from tight third to omniscient (I actually quite like little omniscient asides).

Strengths

The diversity of characters. The description of the secondary worlds: the harsh "high logic" faerielands; the "high nonsense" nonsense worlds; the ones with rhymes, the underworlds, etc etc. It is all very memorable.

Random thoughts

I know I can be too optimistic here, and it can be impossible to stop bullying, but I also just despair at how it's taken for granted in so many situations fictional and real. Here there's a fairly small group of children, with several adults present full time. Can't they at least TRY to prevent at least physical attacks? And ideally violent threats?

Spoilers )

Emojulution Match!

Jul. 17th, 2017 11:04 pm
jack: (Default)
[personal profile] jack
The android game I wrote last month is available for download (see bottom of this post).

Gameplay

It's a variant on an augmented reality match three game. Physically walk around to change which square is highlighted with a light grey background. Click that square to place the next tile there. The next tile is shown at the bottom of the screen. Match three of the same type in a row, and they vanish forming a new type. Then try to match three of *those*. When you reach hearts, match three hearts of any colour and they vanish entirely (but give lots of score).

For instance, three fish next to each other in a line make an octopus, three octopuses make a whale, three whales make a blue heart, three hearts of any colour vanish entirely. And similarly for the three other starter animals.

Only vertical and horizontal. But if you make a line of four, or two crossing lines of three, they all vanish. They only give one new tile, but you get more points.

It would be trivial to play if you could just click on a square, but it's surprisingly addictive when you play it walking about.

Be careful not to walk into the middle of roads! It's surprisingly easy to make that mistake when you're concentrating on your location in the game.

The screen wraps round, so you can always keep walking in one direction rather than walk in the opposite direction. It's best to start by figuring out which compass direction corresponds to which direction on the grid :)

Tips: When you complete an octopus, think about where you're going to put the fish to make the next octopus next to the first one.

Details

If you open the .apk file on an android device, it should ask if you want to install it. You can only do so if you agree to install apps which come from me not the play store. I think that should work but I don't know for sure.

It is very early stages. It seems to work on one or two devices, but I haven't tested it more extensively than that. It will hopefully be ok, but I don't know for sure. I would appreciate knowing everyone who tried it, just whether it ran ok or not, and if the game itself seemed to work.

It still has some UI from the open source OpenSudoku game I based the code on. Don't pay any attention to the menus or help.

File:

https://www.dropbox.com/s/md5sjt25xe3eean/emojilution-debug.apk

(Let me know if the link doesn't work. You should *not* need a dropbox account to use it, but you may have to scroll to the bottom of the screen to continue to download without one.)

Feedback

I would appreciate knowing everyone who tried it, just whether it installed ok or not, and if the game itself seemed to work.

Lots of things are known to be unfinished, so don't waste energy enumerating what's missing in menus etc. Do let me know anything that seems to prevent me playing the game. Do ask if it doesn't run or it's not obvious what to do. Comments on what's fun and what isn't are very much appreciated!

Thank you!

dispatches

Jul. 16th, 2017 10:13 am
kaberett: Overlaid Mars & Venus symbols, with Swiss Army knife tools at other positions around the central circle. (Default)
[personal profile] kaberett
So far today I have spontaneously woken up before 9am, un/loaded the dishwasher, and made myself pancakes (using batter from the freezer; thank you, past Alex). I do not feel a pressing need to immediately go back to sleep.

Yesterday, I swapped over which brand of fexofenadine I was taking (Chanelle Medical to Dr Reddy's, self), had an afternoon nap, and woke up feeling actually refreshed.

I don't care if this is entirely placebo effect, I'll take it.

(I'm pretty sure it's not, though -- I think my post-nasal drip is also reducing again. So.)
Page generated Jul. 28th, 2017 02:49 pm
Powered by Dreamwidth Studios