Re: PATCH: two slab-like memory allocators

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: PATCH: two slab-like memory allocators
Date: 2016-10-25 22:54:47
Message-ID: b5d04d86-5a89-457c-e82f-c52b8ebc6be6@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/1/16 7:34 PM, Tomas Vondra wrote:
>> + /* otherwise add it to the proper freelist bin */
>> Looks like something went missing... :)
>>
>
> Ummm? The patch contains this:
>
> + /* otherwise add it to the proper freelist bin */
> + if (set->freelist[block->nfree])
> + set->freelist[block->nfree]->prev = block;
> +
> + block->next = set->freelist[block->nfree];
> + set->freelist[block->nfree] = block;
>
> Which does exactly the thing it should do. Or what is missing?

What's confusing is the "otherwise" right at the beginning of the function:

+static void
+add_to_freelist(Slab set, SlabBlock block)
+{
+ /* otherwise add it to the proper freelist bin */
+ if (set->freelist[block->nfree])
+ set->freelist[block->nfree]->prev = block;
+
+ block->next = set->freelist[block->nfree];
+ set->freelist[block->nfree] = block;
+}

Otherwise what? What's the other option?

(Haven't looked at the newer patch, so maybe this isn't an issue anymore.)
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532) mobile: 512-569-9461

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chapman Flack 2016-10-25 22:56:28 9.6, background worker processes, and PL/Java
Previous Message Jim Nasby 2016-10-25 22:45:21 Re: emergency outage requiring database restart