Skip to content

Commit 2184423

Browse files
authored
Merge pull request #1364 from martin-frbg/shmem-init
Handle shmem init failures in cpu affinity setup code
2 parents 9251a2e + 07e7c36 commit 2184423

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

driver/others/init.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIA
2626
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2727
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2828
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
29+
kOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
3030
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
3232
**********************************************************************************/
@@ -635,6 +635,8 @@ static int open_shmem(void) {
635635

636636
int try = 0;
637637

638+
int err = 0;
639+
638640
do {
639641

640642
#if defined(BIGNUMA)
@@ -652,18 +654,22 @@ static int open_shmem(void) {
652654
#endif
653655
}
654656

657+
if (shmid == -1) err = errno;
658+
655659
try ++;
656660

657661
} while ((try < 10) && (shmid == -1));
658662

659663
if (shmid == -1) {
660-
perror ("Obtaining shared memory segment failed in open_shmem");
664+
fprintf (stderr, "Obtaining shared memory segment failed in open_shmem: %s\n",strerror(err));
665+
fprintf (stderr, "Setting CPU affinity not possible without shared memory access.\n");
661666
return (1);
662667
}
663668

664669
if (shmid != -1) {
665670
if ( (common = shmat(shmid, NULL, 0)) == (void*)-1) {
666671
perror ("Attaching shared memory segment failed in open_shmem");
672+
fprintf (stderr, "Setting CPU affinity not possible without shared memory access.\n");
667673
return (1);
668674
}
669675
}
@@ -679,11 +685,13 @@ static int create_pshmem(void) {
679685

680686
if (pshmid == -1) {
681687
perror ("Obtaining shared memory segment failed in create_pshmem");
688+
fprintf (stderr, "Setting CPU affinity not possible without shared memory access.\n");
682689
return(1);
683690
}
684691

685692
if ( (paddr = shmat(pshmid, NULL, 0)) == (void*)-1) {
686693
perror ("Attaching shared memory segment failed in create_pshmem");
694+
fprintf (stderr, "Setting CPU affinity not possible without shared memory access.\n");
687695
return (1);
688696
}
689697

0 commit comments

Comments
 (0)